SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SELECT variables from one page and show on another PLEASE HELP.

    Hi guys, recently had a previous post but nether seemed to crack the problem.

    If it helps take a look at my previous thread http://www.sitepoint.com/forums/showthread.php?t=506441

    Ok, I'm taking photographs 4 nights a week at different events and venues, previously I was just shooting 1 event or 1 venue a night, so I had no problem when I needed to call 1 date to show the photos from my 'table'. But now I'm shooting 3 - 4 venues&events in the one night, so I can no longer use my PK (date)from the 'photos table'.

    So my tables, which will soon get updated to reflect the venue, event and so on.. but this is what I have now:

    gallery details
    some_id PK
    venue_id
    event_id
    date

    photos
    photo_id PK
    event_id
    venue_id
    date
    views

    gallery_details belongs to gallery1.php which has this snippet which links to gallery2.php and only selects the variables that are present from 'galley_details', because event_id and venue_id can some times be NULL:
    PHP Code:
    require_once('includes/mysql_connect.inc.php');

        
    $query "SELECT event_id, venue_id, DATE_FORMAT(date, '%d/%m/%y') AS dr2, date FROM gallery_details ORDER BY date DESC";
        
    $res mysql_query($query);
        while (
    $row1 mysql_fetch_assoc($res)) {

        
    // Build the link even with null values.
        
    $link 'gallery2/' $row1['event_id'] . '/' $row1['venue_id'] . '/' $row1['date'];

        
    // Clean up the link strip out excess forward slashes (//, ////).
        
    $link preg_replace('~/{2,}~''/'$link);

        
    // If both event_id and venue_id are not empty then add @ between them.
        
    if (!empty($row1['event_id']) && !empty($row1['venue_id'])) {
            
    $text $row1['event_id'] . '@' $row1['venue_id'];
        } else {
            
    $text $row1['event_id'] . $row1['venue_id'];
        }

        
    // How should it look when we output. %s = string data, Three postions total.
        
    $form '%s - <a href="%s">%s</a><br>';

        
    // Take the format above and process it using the below function inserting
        // the data of our chocie in the postion of our choice.
        
    printf($form$row1['dr2'], $link$text);


    'photos' which belongs to gallery2.php which i want to show the photos from that $date and $event and $venue from gallery1.php what ever it sends over..

    Which says - Not Found
    The requested URL /gallery2/event/venue/2007-09-29 was not found on this server.

    PHP Code:
    $sql "SELECT photo_id, event_id, venue_id, DATE_FORMAT(date, '%d%m%y') AS subdir, views, caption FROM photos 
        WHERE venue_id = 
    $venue_id AND event_id = event_id AND date= $date";
        
    $result = @mysql_query($sql) or die('Error: ' mysql_error());
        for (
    $i 0$row mysql_fetch_array ($result); $i++) {
        if((
    $i != 0) and (($i 8) == 0))
        echo
    '<p></p>';
        echo 
    '<a href="photo/' $row['photo_id'] . '" class="thumb"><img src="thumbs/' $row['subdir'] . '/'$row['photo_id'] . '.jpg" title="Views: ' $row['views'] . '"></a>';
        } 
    How can I adjust the above to show the url. ../event/venue/date?

    PLEASE HELP! I'm out again all this weekend and need to get this sorted, BIG THANKS!

    Any question please ask.
    Last edited by computerbarry; Oct 12, 2007 at 09:39.

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    you need to create a .htaccess file, and use MOD REWRITE to map the url:
    ../someevent/somevenue/somedate to gallery2.php?event=someevent&venu=somevenue&date=somedate
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes cheers i already have my .htaccess file:
    Code:
    RewriteRule ^/?gallery2/([a-zA-Z0-9-]+)$ gallery2.php?event_id=$1&venue_id=$2&date=$3 [L]
    I think this is the problem? unless you can see any problems with the above?
    PHP Code:
    $sql "SELECT photo_id, event_id, venue_id, DATE_FORMAT(date, '%d%m%y') AS subdir, views, caption FROM photos 
        WHERE venue_id = 
    $venue_id AND event_id = event_id AND date= $date";
        
    $result = @mysql_query($sql) or die('Error: ' mysql_error());
        for (
    $i 0$row mysql_fetch_array ($result); $i++) {
        if((
    $i != 0) and (($i 8) == 0))
        echo
    '<p></p>';
        echo 
    '<a href="photo/' $row['photo_id'] . '" class="thumb"><img src="thumbs/' $row['subdir'] . '/'$row['photo_id'] . '.jpg" title="Views: ' $row['views'] . '"></a>';
        } 
    Cheers cb

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    for one, there's an event_id problem.
    PHP Code:
    event_id event_id 
    should be
    PHP Code:
    event_id $event_id 
    also, The mod_rewrite should be:
    PHP Code:
    RewriteRule ^/gallery2/(.*)/(.*)/(.*)$ gallery2.php?event_id=$1&venue_id=$2&date=$[L
    I'm not great with regex - but I think it'll work
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks arkinstall, but still does the same:

    Not Found
    The requested URL /gallery2/somevenue/2007-09-14 was not found on this server.

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    did you upload the file in ascii format?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sure it's nothing to do with my .htaccess file, I've uploaded it the same way for months and never had a problem unless the syntax from wrong.

    gallery1.php - shows the links like:
    ./event/2007-09-12 0r ./event/venue/2007-09-12

    so when clicked i want it to show the the photos and details from those variables, the column data.

    ?

    thanks

  8. #8
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    just checking - does your .htaccess file have:
    PHP Code:
    RewriteEngine On 
    in it?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  9. #9
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've added var_dump($sql); and tried var_dump($result);

    Both give this error:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND event_id = AND date=' at line 56

    thanks

    RewriteEngine On - yes

  10. #10
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    look's like event ID isn't passing to $_GET['event_id'];
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  11. #11
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how do you fix the problem?

    Cheers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •