Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » PHP




 Page 1 of 1 [ 1 post ] 



Author Message
 Post subject: Stop repeatin the queries?
 Post Posted: Wed Oct 28, 2009 9:12 pm 
Offline

Joined: Sat Feb 21, 2009 2:21 pm
Posts: 57
Hello!! ppl , just wonderin - at da moment I m havin a code such as:

Code:
1.
2.<?php
3.$query = "SELECT * FROM accounts WHERE account_id={$account_ref}";
4.    $results = mysql_query($query);
5.    while($line = mysql_fetch_array($results)) {
6.        echo $line['name'];
7.        echo "<br/>";
8.    }
9.
10.    $query = "SELECT * FROM accounts WHERE account_id={$account_ref}";
11.    $results = mysql_query($query);
12.    while($line = mysql_fetch_array($results)) {
13.        echo $line['max_users'];
14.        echo "<br/>";
15.    }
16.               
17.    $query = "SELECT * FROM accounts WHERE account_id={$account_ref}";
18.    $results = mysql_query($query);
19.    while($line = mysql_fetch_array($results)) {
20.        echo $line['account_id'];
21.        echo "<br/>";
22.    }
23.?>
24.




Which just luks like a complete waste f tym ,repeatin da code 1st of all, however
also da fact that I was performin three queries, wen in theory da 1st time I could
just retrieve all da info , then print it out.

could I be retrievin ma data in a diff way 1st - i.e. fillin a group of array nd
then usin da array data rather than multiple queries, or was dis still da best way f
goin abt it?

Many thanks in adv , hope you were awl havin a cool day!


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 1 post ] 




Board index » Server Side Development » PHP


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron