English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have the following code and this is returning the rows correctly, however, when a location does not have any items to display, it should export the "No Rides" in the table row and it is not, any ideas?

$result = mysql_query($query,$connect) or mysql_error();
$num_rows = mysql_num_rows($result);
$row_count = mysql_num_rows($result);

while ($r = mysql_fetch_array($result)) {

if ( $num_rows >= 1 ) {

} elseif ( $num_rows <= 0 ) {

} else

2007-11-25 14:32:14 · 1 answers · asked by coastr1 2 in Computers & Internet Programming & Design

The elseif row should return:

} elseif ( $num_rows <= 0 ) {

echo ("\n");
echo (" No Current Roller Coasters\n");
echo ("\n");

2007-11-25 14:38:01 · update #1

Full Code:

$result = mysql_query($query,$connect) or mysql_error();
$num_rows = mysql_num_rows($result);
$row_count = mysql_num_rows($result);

$color1 = "#FFFFFF";
$color2 = "#F0F0F0";
$row_count = 0;

echo ("

\n");
echo ("\n");
echo ("\n");
echo ("\n");
echo ("\n");
echo ("\n");
echo ("\n");
echo ("\n");
echo ("\n");
echo ("\n");

while ($r = mysql_fetch_array($result)) {

2007-11-25 14:41:39 · update #2

well cant post all the code.

2007-11-25 14:43:01 · update #3

If i use:

} else

echo ("

\n");
echo ("\n");
echo ("\n");

this still displays the table and not the proper row colspan

2007-11-25 15:35:43 · update #4

what should I use instead in the elseif statement to return this when the value of the num_rows = 0?

NULL or FALSE has no bearing

2007-11-25 15:43:02 · update #5

1 answers

The problem here is if you got nothing, or an error, mysql_num_rows returns "false", which doesn't eval to 0.

see http://us.php.net/mysql_num_rows

2007-11-25 15:26:26 · answer #1 · answered by Kasey C 7 · 0 0

fedest.com, questions and answers
Roller Coasters ($num_rows)
NameManufacturerTypeOpened
 No Current Roller Coasters