How can I get the number of entries retrieved by a "SELECT - FROM" Thanks!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dell 4500, mem 1g, disk 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30,
httpd_2.0.44

Thanks to Paul DuBois, Roger Davis, Helen Sallee, Ronan Chilvers, and Edward
Dudlik
for thier response to my question.  I've included the a (one of many?)
snippit of code that
I've decided to use as a pattern for a (class) to be developed.

Thanks again:

Ed anderson

<html><head><title>sample.php</title></head>
<body>
sample.php <BR>
see page 405 "msql cookbook" for code used to develop $h_nrows <BR>
<?php
#
$mysql_connect = mysql_connect("localhost", "root")
           or die ("mysql_connect $mysql_connect\n");
mysql_select_db("mysql", $mysql_connect)
                or die ("mysql_select_db $mysql_connect\n");
#
$h_id1 = "3"; $h_id2 = "4"; $h_id3 = "5";
$t = "<td>"; $tn = "</td>";
$r = "<tr>"; $rn =  "</tr>";
#
$h_query = " SELECT  *
    FROM employees
      WHERE  id=$h_id1  OR  id=$h_id2  OR  id=$h_id3";
 printf("mysql_query: $h_query<br>\n");
#
$h_result_id =  mysql_query($h_query, $mysql_connect);
 if(! $h_result_id)
      die (" mysql_query h $mysql_connect\n");
 $h_nrows = @mysql_num_rows ($h_result_id);
#
if ($h_nrows == 0)
 print ("Note: h query has no result set\n");
  $dat_h_id  = mysql_result($h_result_id,$i,"id");
  $dat_first = mysql_result($h_result_id,$i,"first");
  $dat_last  = mysql_result($h_result_id,$i,"last");
#
#
#
echo "<table border=1 cellspacing=0>";
for ($i = 0; $i < $h_nrows; $i++)
{ echo "$r";
   $dat_h_id  = mysql_result($h_result_id,$i,"id");
    echo "$t  $dat_h_id$tn";
    $dat_first = mysql_result($h_result_id,$i,"first");
    echo "$t  $dat_first$tn";
    $dat_last  = mysql_result($h_result_id,$i,"last");
    echo "$t  $dat_last $tn";
    echo "$t  $i        $tn";
    echo "$t  $h_nrows  $tn";
    echo "$rn";
} echo "</table>";
#
?>
<BR>
sample.php end <BR><BR>
</body>
</html>

using mozilla browser -    http://127.0.0.1/sample.php

sample.php
see page 405 "msql cookbook" code used to develop $h_nrows
mysql_query: SELECT * FROM employees WHERE id=3 OR id=4 OR id=5
3 Brad   Johnson 0 3
4 aa       bb         1 3
5 WW   EE         2 3


sample.php end


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux