Jump to content

if a query returns nothing echo "NO DATA"


seefor

Recommended Posts

Sorry for the new user question, I wasn't sure what to Google.  ??? ???

 

I'm trying to take the code below and when the query return nothing, it will say NO ERRORS.

 

Any help would be greatly appreciated.

 

<?php require_once('../Connections/hdconus.php'); ?>
<?php
mysql_select_db($database_hdconus, $hdconus);
$query_Recordset1 = "SELECT * FROM hdconus WHERE (hdconus.lostPackets != 0 OR hdconus.correctedPackets != 0 OR hdconus.uncorrectedPackets != 0 OR hdconus.fifoOverflow != 0 OR hdconus.fifoUnderflow != 0) AND `time` = '12:30' AND hdconus.`date` = '03/04/09' ";
$Recordset1 = mysql_query($query_Recordset1, $hdconus) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_free_result($Recordset1);
?>
<table border="1">
  <tr>
    <td>id</td>
    <td>unitAlias</td>
    <td>mcastSourceIPAddr</td>
    <td>mcastGroupIPAddr</td>
    <td>lostPackets</td>
    <td>correctedPackets</td>
    <td>uncorrectedPackets</td>
    <td>fifoOverflow</td>
    <td>fifoUnderflow</td>
    <td>jitterTolerance</td>
    <td>mgmtIPAddr</td>
    <td>unitNotes</td>
    <td>date</td>
    <td>time</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Recordset1['id']; ?></td>
      <td><?php echo $row_Recordset1['unitAlias']; ?></td>
      <td><?php echo $row_Recordset1['mcastSourceIPAddr']; ?></td>
      <td><?php echo $row_Recordset1['mcastGroupIPAddr']; ?></td>
      <td><?php echo $row_Recordset1['lostPackets']; ?></td>
      <td><?php echo $row_Recordset1['correctedPackets']; ?></td>
      <td><?php echo $row_Recordset1['uncorrectedPackets']; ?></td>
      <td><?php echo $row_Recordset1['fifoOverflow']; ?></td>
      <td><?php echo $row_Recordset1['fifoUnderflow']; ?></td>
      <td><?php echo $row_Recordset1['jitterTolerance']; ?></td>
      <td><?php echo $row_Recordset1['mgmtIPAddr']; ?></td>
      <td><?php echo $row_Recordset1['unitNotes']; ?></td>
      <td><?php echo $row_Recordset1['date']; ?></td>
      <td><?php echo $row_Recordset1['time']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>

 

Thanks in advanace

Link to comment
https://forums.phpfreaks.com/topic/148265-if-a-query-returns-nothing-echo-no-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.