Solved

how to write this in coding terms?

Posted on 2009-07-05
2
169 Views
Last Modified: 2012-05-07
how to write in the programing language that

if there is no record in the database the show the message
Empty Records
else show all the records from the database.

0
Comment
Question by:designersx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
aamodt earned 125 total points
ID: 24782831
Something like this .. ofc needs modification to work in your DB

This is MySQL by the way, dont know what you want :)

Regards Aamodt
<?php
 
mysql_connect('ipaddress','username','password');
mysql_select_db('database');
 
$result = mysql_query("SELECT * FROM table where field='something'");
 
if(mysql_num_rows($result) != 1) { echo 'Empty Records'; } else {
while ($row = mysql_fetch_array($result)) {
echo $row['id'].' - '.$row['test'].'<br />';
}
}

Open in new window

0
 
LVL 9

Expert Comment

by:Shahzad Fateh Ali
ID: 24782896
Hi aamodt,

I have done a little modification in your code.

<?php
mysql_connect('ipaddress','username','password');
mysql_select_db('database');
 
$result = mysql_query("SELECT * FROM table where field='something'");
 
if(mysql_num_rows($result) == 0) { 
	echo 'Empty Records';
} else {
	while ($row = mysql_fetch_array($result)) {
		echo $row['id'].' - '.$row['test'].'<br />';
	}
}
 
?>

Open in new window

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question