Forum Moderators: coopster
For Example,
Column1--> AK
Result 1--> alphabetized list of dealers in AK
Column2--> AL
Result 2--> alphabetized list of dealers in AL
In addition, each dealer needs to have a checkbox next to delaer name.
What query do I need to send to the database?
How can I format the page results so that all states appear on screen in an easy to read format?
thanks
SELECT state_name, dealer_name FROM dealers ORDER BY state_name, dealer_name
or, if you have a bit more complex DB
SELECT s.state_name, d.dealer_name
FROM dealers d, states s
WHERE d.state_id=s.state_id
ORDER BY s.state_name, d.dealer_name
"select dealer_id, name, city,zip FROM `dealer` order by state,name"
I need to be able to show all states and associated dealers alphabetized. I would like state to be the column header
and dealers with a checkbox next to name underneath.
Thanks for your assistance
Let's say, for example, that you have done the SELECT mentioned and your result set has $row['dealer'' and $row['state']
$num_cols = 4; // or however many you have
$state = '';
$table = '<table>';
while ($row = mysql_fetch_assoc($result))
{
if ($state!= $row['state'])
{
$table .= '<tr><td class="state_header" colspan="' . $num_cols . '">' . $row['state'] . '</td></tr>';
}
$table .= '<tr class="dealer">
<td>'. $row['dealer_name'] . '</td>
<td>'. $row['dealer_street'] . '</td>
<td>'. $row['dealer_city'] . '</td>
<td>'. $row['dealer_zip'] . '</td>
</tr>';
}
$table .= '</table>';
Something along those lines