Jump to content

efficiency question


Derleek

Recommended Posts

I always run into this problem and i'm curious what would be the most efficient way to approach it.

 

I have to select up to 65 names from a database and display them in 10 different drop down menu's.

 

would it be more efficient to run a bit of code 650 times

 

code: (i am not sure if the MySQL stuff is right, i'm new and experimenting  ;D)

<?
//QUERY to set the rider ID for pre-entry list of race
$query = "SELECT racer_id FROM race_racer WHERE race_id = $race_id AND class_id = $class_id"; 

$result = mysql_query($query) or die(mysql_error());

$R_id = array();

while($row = mysql_fetch_array($result,MYSQL_ASSOC))
	{
	$R_id= $row['racer_id'];
	$q=0;
	$sql = "SELECT name FROM Racers WHERE racer_id = $r_id";
	$result = mysql_query($sql) or die(mysql_error());
	$row = $result;
		$name =$row;
	}

?>

 

or store all of the names into an array and go through the array 10 times.

 

Once again i'm relatively new to the php/MySQL realms so go easy on me  ;)

 

Link to comment
https://forums.phpfreaks.com/topic/113105-efficiency-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.