Connecting Tech Pros Worldwide Help | Site Map

a questions about mysql_fetch_array()

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:58 AM
lsarg
Guest
 
Posts: n/a
Default a questions about mysql_fetch_array()

whenever i use this, i'm leaving out one item from the array. in other
words, one row from the table i'm querying won't show up. i'm new at
php, and this is probably a simple thing, but please help of you can.
here's an example that leaves out the most recent submission:

$query = "SELECT topic, message, author, DATE_FORMAT(posted, '%M %e,
%Y') AS d FROM messageboard ORDER BY posted DESC";

$result = @mysql_query ($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);


while ($row = mysql_fetch_array ($result, MYSQL_ASSOC) ) {

echo"<p> {$row['topic']}<br>
{$row['message']}
<br>Posted by {$row['author']} on {$row['d']}
<br>";

}

  #2  
Old July 17th, 2005, 04:58 AM
Tim Van Wassenhove
Guest
 
Posts: n/a
Default Re: a questions about mysql_fetch_array()

In article <4c3827cd.0404241052.36a88b62@posting.google.com >, lsarg wrote:[color=blue]
> whenever i use this, i'm leaving out one item from the array. in other
> words, one row from the table i'm querying won't show up. i'm new at
> php, and this is probably a simple thing, but please help of you can.
> here's an example that leaves out the most recent submission:
>
> $query = "SELECT topic, message, author, DATE_FORMAT(posted, '%M %e,
> %Y') AS d FROM messageboard ORDER BY posted DESC";
>
> $result = @mysql_query ($query);
> $row = mysql_fetch_array($result, MYSQL_ASSOC);[/color]

here $row contains the first row that is returned from your query
[color=blue]
> while ($row = mysql_fetch_array ($result, MYSQL_ASSOC) ) {[/color]

the first time you here, $row will containt the 2nd row from your query[color=blue]
> }[/color]

Suggestion: Leave the first $row = mysql_fetch_assoc($result) away.

--
http://home.mysth.be/~timvw
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.