Grow your CSS skills. Land your dream job.

Need to change when gig list deletes shows

  • # December 7, 2010 at 4:38 pm

    Do you have the SQL code it is using to call the data from the database?

    I’m guessing there will be a statement that says something like “SELECT * FROM Events WHERE EventDate > NOW()”. JUst change the “>” to “>=”.

    # December 8, 2010 at 11:59 am

    Thanks TT_Mark. Here it is.

    < ?php

    /* build output */
    $query = 'SELECT show_id, date_starts, stime, venue, url, city, state,
    DATE_FORMAT(date_starts,'%b %e') as ds
    FROM shows
    WHERE date_starts >= NOW()
    ORDER BY date_starts ASC';
    $result = mysql_query($query,$DATABASE_LINK) or die(mysql_error().': '.$query);
    if(mysql_num_rows($result))
    {
    //heading


    //for every show date
    while($row = mysql_fetch_assoc($result))
    {
    //reset vars
    $address = $dates = $event_venue = '';

    //start row
    $table.= '
    ';

    //show dates
    //$dates = $row.($row && $row!= $row ? ' - '.$row : '');
    $dates = $row;
    $table.= '
    '.$dates.'
    ';

    //show event/venue
    if($row) { $event_venue.=''; }
    //if($row) { $event_venue.= $row; }
    //if($row && $row) { echo '
    '; }
    if($row) { $event_venue.= $row; }
    if($row) { $event_venue.='
    '; }
    $table.= '
    '.$event_venue.'
    ';

    //build & show address
    //if($row) { $address.= $row.'
    '; }
    if($row) { $address.= $row; }
    if($row && $row) { $address.= ', '; }
    if($row) { $address.= $row; }
    //if($row) { $address.= ' '.$row; }
    $table.= '
    '.$address.'
    ';

    //show time
    $table.= '
    '.($row ? $row : '&nbsp').'
    ';

    //admin?
    if($_SESSION)
    {
    $table.= '';
    }

    //end row
    $table.= '
    ';
    $table.= '
    ';
    }
    }
    else
    {
    //output general message
    $table = '

    Sorry! There is no show information available at this time. Check back soon!

    ';
    }

    ?>
    # December 8, 2010 at 2:24 pm

    Hmm…that SQL statement looks right, did you change it to that or was it set to that already?

     $query = 'SELECT show_id, date_starts, stime, venue, url, city, state,
    DATE_FORMAT(date_starts,'%b %e') as ds
    FROM shows
    WHERE date_starts >= NOW()
    ORDER BY date_starts ASC';

    This is the important bit, basically says pick anything where date is either today or in the future

    # December 9, 2010 at 11:36 am

    I didn’t change it. Shows are still being deleted at the beginning of the day. Can I change that code somehow to tell it to delete a few days after the event?

    # December 9, 2010 at 3:00 pm

    If you can add one day to the query it would delete them the day after. My SQL knowledge suck but it should be doable by replacing the WHERE:

    WHERE date_starts >= DATE_ADD(NOW(), INTERVAL 1 DAY)

    This was modified from: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_adddate

    It might work :-p.

    # December 10, 2010 at 11:07 am

    Thanks all. Added a “-” to the 1 and it worked.

    # December 10, 2010 at 12:17 pm

    I was close!! Glad it helped…

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".