is it visible to query a table in mysql in several times???
Posted by: ryanpaul04 (119.95.74.---)
Date: June 06, 2008 01:01PM

is it visible to query a table in mysql in several times??

ex.

$result = mysql_query("SELECT * FROM table"winking smiley;

while($row1=mysql_fetch_array($result))
{
echo $row1['data1'];
}


while($row2=mysql_fetch_array($result))
{
echo $row2['data2'];
}

is this right???? i'm not a pro in this mysql thing ^^

Options: ReplyQuote
Re: is it visible to query a table in mysql in several times???
Posted by: yfastud (Moderator)
Date: June 06, 2008 02:02PM

Fetch 1, then get results out in different positions instead

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides



Edited 1 time(s). Last edit at 06/06/2008 02:35PM by yfastud.

Options: ReplyQuote
Re: is it visible to query a table in mysql in several times???
Posted by: toivo (---.nsw.bigpond.net.au)
Date: June 06, 2008 02:33PM

If data1 and data2 are columns in the table, you can list all the rows like this:

while($row = mysql_fetch_array($result)) {
echo '<p>data1=' . $row['data1'] . ' data2=' . $row['data2'] . '</p>';
}

Regards,

toivo
Sydney, Australia

Options: ReplyQuote
Re: is it visible to query a table in mysql in several times???
Posted by: Rhodizzle (---.hsd1.co.comcast.net)
Date: June 06, 2008 07:16PM

The order always goes like this

1. prepare query

2. execute query

3. format results

4. write results into your $document variable if you're using it, otherwise display your results.

In the code that you gave you aren't querying MySQL multiple times, you are querying it once with the $result line, then using the array that it feeds back multiple times. Its always better performance to gather as much data from MySQL with a single query as you can, then once you have it in variable form you can store it somewhere. Check into how to use PHP sessioning to improve DB results for data that doesn't change often.

Options: ReplyQuote
Re: is it visible to query a table in mysql in several times???
Posted by: ryanpaul04 (119.95.68.---)
Date: June 07, 2008 04:28AM

thanks for the reply pipz ^^

but i have solve my question ^^

thanks again ^^

Options: ReplyQuote


Sorry, only registered users may post in this forum.