
November 8th, 2002, 12:57 PM
|
|
|
|
Join Date: Apr 2007
Posts: 125
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
mysql_num_rows()
Can anyone tell me why $num_results returns 1 even when there are more than 1 result displayed on the page? If there are 0 results then 0 is displayed correctly.
Here is the code
php Code:
Original
- php Code |
|
|
|
dbconnect(); $sql = "SELECT * FROM $table WHERE status = 'New'"; if ($num_results != 0) { if($num_results = 1) { $grammar1 = "is"; $grammar2 = "request"; } else { $grammar1 = "are"; $grammar2 = "requests"; } page_header(); ?> <tr> <td height="370" align="center" valign="top"> <div align="right" class="vsmall">Logged in as <?php echo $fname ?> <?php echo $sname ?><br> </div> <table width="95%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16%"><div align="center" class="tbldata"><img src="../images/down-unassrqsts.gif" width="132" height="21"></div></td> <td width="2%"> </td> <td width="16%"><div align="center" class="tbldata"><a href="myqueue.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('myqueue','','../images/down-<?php echo $fname ?>.gif',1)"><img src="../images/up-<?php echo $fname ?>.gif" alt="<?php echo $fname ?>'s queue" name="myqueue" width="132" height="21" border="0"></a></div></td> <td width="2%"> </td> <td width="16%"><div align="center"><a href="business.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('business','','../images/down-business.gif',1)"><img src="../images/up-business.gif" alt="Business Travel Requests" name="business" width="132" height="21" border="0"></a></div></td> <td width="2%"><div align="center"></div></td> <td width="16%"><div align="center"><a href="reports.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('reports','','../images/down-reports.gif',1)"><img src="../images/up-reports.gif" alt="View reports" name="reports" width="132" height="21" border="0"></a></div></td> <td width="2%"> </td> <td width="16%"><div align="center"><a href="logout.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('logout','','../images/down-logout.gif',1)"><img src="../images/up-logout.gif" alt="Logout" name="logout" width="132" height="21" border="0"></a></div></td> </tr> </table> <br> <table width="95%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan= "4" class= "tbldata">There <?php echo $grammar1 ?> currently <?php echo $num_results ?> new travel <?php echo $grammar2 ?> awaiting to be assigned and actioned.</td> </tr> </table> <br> <table width="95%" cellspacing="0" cellpadding="0"border="1" bordercolor="#800000"> <tr class="tbldata"> <td><div align="center"><strong>Request ID</strong></div></td> <td><div align="center"><strong>Request By</strong></div></td> <td><div align="center"><strong>Date of Departure</strong></div></td> <td><div align="center"><strong>Outbound Route</strong></div></td> <td><div align= "center"><strong>Date / Time of Request</strong></div></td> </tr> <?php { $ID = $request_data['id']; $StaffName = $request_data['staffname']; $DateOfDeparture = $request_data['dod']; $OutboundRoute = $request_data['flight_route1']; $DateOfRequest = $request_data['date_of_request']; $TimeOfRequest = $request_data['time_of_request']; ?> <tr class="tbldata"> <td><div align= "center"><a href= "assign.php?id=<?php echo $ID ?>" class= "tbldata"> 000<?php echo $ID ?></a></div></td> <td><div align= "center"><?php echo $StaffName ?></div></td> <td><div align= "center"><?php echo $DateOfDeparture ?></div></td> <td><div align= "center"><?php echo $OutboundRoute ?></div></td> <td><div align= "center"><?php echo $DateOfRequest ?> <em> [<?php echo $TimeOfRequest ?>]</em></div></td> </tr> <?php } ?> </table> </td> </tr> </table> <?php page_footer(); } else { }
|