Hello, hopefully i can explain myself i have a table with driver details there are 6 drivers.. im trying to order the drivers on a table by priority i think the best way to do it would be with a loop? but i'm not very familiar with loops yet.. i have been trying something with no success...
this is what i wrote but like i said im not very familiar with loops i didnt succeed
PHP Code:
$sql_driver = "SELECT dr_id,dr_name FROM driver_details ";
$res_driver = mysql_query($sql_driver)or die(mysql_error());
while($row_driver = mysql_fetch_assoc($res_driver)){
$dr_id = $row_driver['dr_id'];
$driver_name = $row_driver['dr_name'];
$dr_data[$dr_id] = $row_driver['dr_name'];
foreach($dr_data as $key => $d_name){
echo "dr_id = " . $key . " name = " . $d_name . "<br/>";
}
}
this is the output i need to get
dr_id = 1 name = George Lopez
dr_id = 2 name = Edgar Mungia
dr_id = 3 name = Keneth Ceballos
dr_id = 4 name = Hugo Sanchez
dr_id = 5 name = Nelson Castro
dr_id = 6 name = Driver 6
and after that i need to order them in the table by priority in this case would be the dr_id i'm not sure how to achieve that either :/ can i define the order of the drivers in the while loop and then display it on the table like this?
thanks for your help
PHP Code:
<table>
<tr>
<td id="left" width="100"><?php echo $driver1;?> </td>
</tr>
<tr>
<td id="left" width="100"><?php echo $driver2;?> </td>
</tr>
<tr>
<td id="left" width="100"><?php echo $driver3;?> </td>
</tr>
<tr>
<td id="left" width="100"><?php echo $driver4;?> </td>
</tr>
<tr>
<td id="left" width="100"><?php echo $driver5;?> </td>
</tr>
<tr>
<td id="left" width="100"><?php echo $driver6;?> </td>
</tr>
</table>
|