I think this is the place for asking this question but please redirect me if I need to go to design/theory.
I have a website functioning as an admin tool for my wedding band. The primary function of this site is to display future gigs and, if selected, past gigs. It also sums up our fees to give us an overview of our gross income. The gigs are displayed on a list and in between them are "no-goes" from band members signalling dates where they are not available for future gigs. Furthermore, there are gigs of two different types, public and private. The only practical and technical difference of these is that public gigs are shown on our main (public) website.
As of now, I have all my records in one table job, where the int field type determines whether the record is a gig, a public gig, or a no-go. In addition, there are fields id, date, place, price, info, and user. A no-go only needs id, date (datetime type), type, info, and user. So we have a lot of place and price fields that are null in the no-go records.
- My first question is whether this is faulty db structure. I've started at the IT University of Copenhagen, Denmark this semester and my lecturers tell me that this way of representing data is not correct, that I need to have separate tables for no-goes and gigs. What is this community's take on the problem?
The reason why I'm considering restructuring is that my current loop code is not pretty. By default you only view future gigs and no-goes, but via a link you can set a GET variable showing all gigs past and future but still only future no-goes. It wouldn't be a problem to include past no-goes for nostalgia reasons but I haven't done it as I wanted to redo my code first.
As you can see, I have two loops, first one only executing if GET variable to include all gigs is set. Second loop includes future gigs and no-goes. My question is whether there is a better way, I know there is, but I can't figure out what would be the smartest thing to do. Can you guide me along the way, just a basic idea of a better structure would be very much appreciated. Thank you for your time.
Code: Select all
if ($allgigs == "1") { // include past gigs if set
$row_past = mysql_fetch_array(mysql_query("SELECT * FROM job WHERE date < NOW() AND type != 3 ORDER BY date ASC"));
while($row_past = mysql_fetch_array($showgigs)) { // While start
// execute loop code, omitted for better overview
}} // END include old gigs
$showgigs = mysql_query("SELECT id, date, type, place, price, info, user FROM job WHERE date > NOW() ORDER BY date ASC") or die(mysql_error());
while($row2 = mysql_fetch_array($showgigs)) { // While start
// execute loop code, omitted for better overview
} // End while