[PHP] Fw: printf %d

2002-12-13 Thread William Martell

- Original Message - 
From: William Martell [EMAIL PROTECTED]
To: [EMAIL PROTECTED];
Sent: Friday, December 13, 2002 2:13 PM
Subject: printf %d


 Hello All.
 
 Can anyone tell me what this '%d' refers to?
 
 A pointer would be great.  Thanks
 
 [snip]
 if (!$result)
  die (Query Failed\n);
 else
  printf (Number of rows returned: %d\nbrbr,
 -HERE '%d'
 mysql_num_rows ($result));
  while ($query_data = mysql_fetch_array ($result))
  {
 
   echo Part#: .$query_data[holman_part].br;
   echo Description: .$query_data[part_desc].brbrbr;
  }
 [/snip]
 


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




[PHP] Fw: Paging / Navigation Question Solved!

2002-12-13 Thread William Martell
Thank you all for your input.  Here is the answer that I was looking for.  I
am posting it here so that anyone else looking for this answer can benefit
as well.

Thank you all again for your responses.

Merry Christmas!!

William
- Original Message -
From: Jay Blanchard [EMAIL PROTECTED]
To: 'William Martell' [EMAIL PROTECTED]
Sent: Friday, December 13, 2002 6:03 AM
Subject: RE: Paging / Navigation Question


 [snip]

 [snip]
 Or another way if you don't want a result when it's zero.
 $rslt = mysql_query(SELECT count(*) as cnt FROM tbl having cnt  0);
 [/snip]

 $result = mysql_query(SELECT * FROM tbl);
 $number_of_rows = mysql_num_rows($result);

 You don't have to do the count in the SQL, as John said earlier a SELECT
 COUNT(*) FROM tbl will always return one row, even if the value of the row
 is 0. Of course you could always test for that.

 CountingRows Solution #317 :^]

 I was reading your post regarding paging and SELECT COUNT(*)

 I don't understand why $number_of_rows will always equal 1.

 I thought that if you SELECT COUNT(*), that you are telling mySQL to count
 all of the rows WHERE some condition is met.

 Please explain???
 [/snip]

 A COUNT query always returns one row, the row which explains how many
 records were counted. It is easier to understand if you know that a row is
 not necessarily equal to a record. For example, look at these count
results
 from MySQL monitor;

 mysql SELECT COUNT(*) FROM tblSubscriber;
 +--+
 | COUNT(*) |
 +--+
 |71896 |
 +--+
 1 row in set (0.01 sec)

 See the last line? 1 row in set (0.01 sec) Of course this is not a
record,
 for the record would have subscriber information over multiple columns.

 Let me know if this is clear.

 Thanks!

 jay


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




[PHP] printf %d

2002-12-13 Thread William Martell
Hello All.

Can anyone tell me what this '%d' refers to?

A pointer would be great.  Thanks

[snip]
if (!$result)
 die (Query Failed\n);
else
 printf (Number of rows returned: %d\nbrbr,
-HERE '%d'
mysql_num_rows ($result));
 while ($query_data = mysql_fetch_array ($result))
 {

  echo Part#: .$query_data[holman_part].br;
  echo Description: .$query_data[part_desc].brbrbr;
 }
[/snip]


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




[PHP] Using - to access hash elements

2002-12-13 Thread William Martell
Can someone shed some light on the '-' syntax seen below.  Is this like
similar to Perl '=' syntax to access hash key value pairs?

Thank you one and all.

[snip]
// print mailing list
while($data = mysql_fetch_object($result)){
   print($data-name . ,  . $data-address . ,  . $data-city . ,  .
$data-state . ,  . $data-zip . \n);
}
[/snip]





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




[PHP] Paging / Navigation Help

2002-12-12 Thread William Martell
Hello ALL.

Can anyone tell me why the number of rows is always 1 and count is the total
number of records in my database.

Thanks in Advance,
William

[snip]

HTML
HEAD
TITLE/TITLE
/HEAD

BODY

?php


 $db = mysql_connect(localhost, root);

 mysql_select_db(dallas, $db);

 $result =  mysql_query(SELECT COUNT(*) as count FROM partscatalog having
count 0;,$db);

 //get number of rows returned
 $number_of_rows = mysql_num_rows($result);

 if ($number_of_rows != '0')
  {
 while ($myrow = mysql_fetch_array($result))
   {
  echo \$number_of_rows is $number_of_rows;
 echo count: .$myrow[count].br\n;

 }
}

?

/body
/html


[/snip]


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