I’m setting up a gig guide for a band. Now, i’ve got the code working EXACTLY as i want it, no dramas at all, but it is extremely long, and extremely messy!
If someone could point me in the right direction, i would love to learn how to do this the SHORT way!
As you will see, i need the months to be seperated by the month heading, and as i said before, this all works great, but pasting the same code 12 times just seems ridiculous, surely there has to be a quicker way
I hope this all makes sense.
Thanks in advance to anyone willing to help out.
Cheers,
Dave
[code] // select January shows in the database
$result = mysql_query(“select show_id, month, day1, day2, year, location, details, venue
from $database_table
where month = ‘1’
order by year, month, day2”,$db)
or die_now(“
Could not select shows
”); echo("<table class='guide'>n");
echo("t<tr>ntt<td width='80'>date</td>ntt<td width='140'>venue</td>ntt<td width='100'>location</td>ntt<td width='200'>details</td>nt</tr>n");
echo("</table>n");
echo("<table class='guide'>n");
echo("t<tr>ntt<td width='80'>January</td>nt</tr>n");
echo("</table>n");
while($row = mysql_fetch_array($result)){
$the_id = $row["show_id"];
$the_month = $row["month"];
$the_day1 = $row["day1"];
$the_day2 = $row["day2"];
$the_year = $row["year"];
$the_location = $row["location"];
$the_details = $row["details"];
$the_venue = $row["venue"];
// shows
echo("<table class='guide'>n");
echo("t<tr>ntt<td width='80'>$the_day1" . " - " . "$the_day2" . "/" . "$the_month" . "</td>n");
echo("tt<td width='140'>" . "$the_venue" . "</td>n");
echo("tt<td width='100'>" . "$the_location" . "</td>n");
echo("tt<td width='200'>" . "$the_details" . "</td>n");
echo("t</tr>n</table>n");
}
// select February shows in the database
$result = mysql_query(“select show_id, month, day1, day2, year, location, details, venue
from $database_table
where month = ‘2’
order by year, month, day2”,$db)
or die_now(“
Could not select shows
”); echo("<table class='guide'>n");
echo("t<tr>ntt<td width='80'>February</td>nt</tr>n");
echo("</table>n");
while($row = mysql_fetch_array($result)){
$the_id = $row["show_id"];
$the_month = $row["month"];
$the_day1 = $row["day1"];
$the_day2 = $row["day2"];
$the_year = $row["year"];
$the_location = $row["location"];
$the_details = $row["details"];
$the_venue = $row["venue"];
// shows
echo("<table class='guide'>n");
echo("t<tr>ntt<td width='80'>$the_day1" . " - " . "$the_day2" . "/" . "$the_month" . "</td>n");
echo("tt<td width='140'>" . "$the_venue" . "</td>n");
echo("tt<td width='100'>" . "$the_location" . "</td>n");
echo("tt<td width='200'>" . "$the_details" . "</td>n");
echo("t</tr>n</table>n");
}
[/code]