Connecting Tech Pros Worldwide Forums | Help | Site Map

mysql_fetch_array

Maximus
Guest
 
Posts: n/a
#1: Jul 2 '06
I do a query that select latest 3 records in the database table.

Now after doing the query, i need to echo it's results in 3 different
tables, 1 big, and 2 small below the big one.

how can i do that?

Geoff Berrow
Guest
 
Posts: n/a
#2: Jul 2 '06

re: mysql_fetch_array


Message-ID: <1151836878.677813.324590@b68g2000cwa.googlegroups .comfrom
Maximus contained the following:
Quote:
>Now after doing the query, i need to echo it's results in 3 different
>tables, 1 big, and 2 small below the big one.
>
>how can i do that?
while($myrow=mysql_query($sql){
$table[]=$myrow;
}

$table is then an array containing your three rows
($table[0],$table[1],$table[2]).

Loop through it using foreach to extract the data any way you choose.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Maximus
Guest
 
Posts: n/a
#3: Jul 2 '06

re: mysql_fetch_array


But the while($row=mysql_query($sql)) {

}

is giving me some infinite loop, the whole pc would freeze as the
script won't stop
any solution? or explanation

Geoff Berrow wrote:
Quote:
Message-ID: <1151836878.677813.324590@b68g2000cwa.googlegroups .comfrom
Maximus contained the following:
>
Quote:
Now after doing the query, i need to echo it's results in 3 different
tables, 1 big, and 2 small below the big one.

how can i do that?
>
while($myrow=mysql_query($sql){
$table[]=$myrow;
}
>
$table is then an array containing your three rows
($table[0],$table[1],$table[2]).
>
Loop through it using foreach to extract the data any way you choose.
>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Rik
Guest
 
Posts: n/a
#4: Jul 2 '06

re: mysql_fetch_array


Maximus wrote:
Quote:
But the while($row=mysql_query($sql)) {
>
}
>
is giving me some infinite loop, the whole pc would freeze as the
script won't stop
any solution? or explanation
Should offcourse be:
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){

}

Now, it's just querying over and over again, and as long as the MySQL
server doesn't return false, it will requery it..

Grtz,
--
Rik Wasmus


Geoff Berrow
Guest
 
Posts: n/a
#5: Jul 2 '06

re: mysql_fetch_array


Message-ID: <8e78b$44a7db5d$8259c69c$7236@news1.tudelft.nlfr om Rik
contained the following:
Quote:
>Should offcourse be:
>$result = mysql_query($sql);
>while($row = mysql_fetch_array($result)){
>
>}

What he said.

Memo to self - don't post before coffee...
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Closed Thread