Solved

how to write this in coding terms?

Posted on 2009-07-05
2
168 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 count occurrences of each item in an array.

752 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