RE: [PHP] Re: Print ONCE ONLY?????
| From: | Pavel Kharitonov | Date: | Sat, 12 Jan 2002 23:25:59 +0000 |
| Subject: | RE: [PHP] Re: Print ONCE ONLY????? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80324@lists.php.net to get a copy of this message | ||
I think this is actually the problem
The first time you do $row = mysql_fetch_array($result); it reads the first
row. Then you don't do anything with that data, but move on to the next one
right away in the while:
while ($row = mysql_fetch_array($result))
and only then you print out the data. So you are always skipping the first
record.
Sincerely,
Pavel Kharitonov
Project Manager
Intechnic Corporation
http://www.intechnic.com
Phone: (847) 816-1231
-----Original Message-----
From: Michael Kimsal [mailto:michael@tapinternet.com]
Sent: Saturday, January 12, 2002 5:14 PM
To: Dani
Cc: PHP LIST
Subject: [PHP] Re: Print ONCE ONLY?????
Dani wrote:
> Hi Again!
>
> Why does this print only one record?
>
> 1. I have checked on the table on MYSQL and I have 2 records with this
> data.
> 2. Can I actually use the word "and" twice or three times for filtering
> the data that I need during query?? (example: $query = "select * from
> main_table where item_type = 'hotel' and class = 'melati' and price =
> '200' and facilities = 'swimming pool' "
>
#2 - yes. that's what SQL is all about...
#1 - Why do the $row=xxxx, then also do it in a while loop? Why not
just do it in a while loop? I'm not sure that'd necessarily help in this
case (most likely won't) but it would certainly be less typing in the
future.
Are you postive 2 rows match the 'hotel' and 'melati'?
> Could some body help please???
>
> here is my code
>
> ...
> $query = "select * from main_table where item_type = 'hotel' and class =
> 'melati'";
> $result = mysql_query($query);
> $row = mysql_fetch_array($result);
> echo "$row[item_id]","<BR>";
> while ($row = mysql_fetch_array($result))
> {
> echo "WHILE
> RESULT","$row[item_type]","<BR>","$row[class]";
> }
>
--------------------------------
Michael Kimsal
PHP Training Courses
http://www.tapinternet.com/php/
734-480-9961
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net