SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Photos aren't displaying???

    My code below displays each property listing that is the database, no problem. Doesn't display the photos that are suppose to match each property listing. Can someone please take a look at my code and tell how I can solve this problem? Thanks in advance.

    PHP Code:
    require "config.php";
    if(!isset(
    $_GET['page'])) {
        
    $page 1;
    } else {
        
    $page $_GET['page'];
    }

    // Define the number of results per page
    $max_results 1;

    // Figure out the limit for the query based
    // on the current page number
    $from = (($page $max_results) - $max_results);

    // Perform MySQL query on only the current page number's results
    $sql mysql_query("SELECT * FROM `ruralproperties` ORDER BY `propertyname` LIMIT $from$max_results") or die ("Could not query because: " mysql_error());

    while(
    $row mysql_fetch_array($sql)){
        
    $image $row['photos'];
        
    $filename $row['photos'];
        
    $propertyname stripslashes($row['propertyname']);
        
    $message1 stripslashes($row['message1']);
        
    $message2 stripslashes($row['message2']);
        
    $message3 stripslashes($row['message3']);
        
    $message4 stripslashes($row['message4']);
        
    $message5 stripslashes($row['message5']);
        
    $message6 stripslashes($row['message6']);
        
    $message7 stripslashes($row['message7']);
        
    $message8 stripslashes($row['message8']);
        
    $message9 stripslashes($row['message9']);
        
    $message10 stripslashes($row['message10']);
        
    $message11 stripslashes($row['message11']);
        
    $message12 stripslashes($row['message12']);
        
    $message13 stripslashes($row['message13']);
        
    $message14 stripslashes($row['message14']);
        
    $message15 stripslashes($row['message15']);
        
    $message16 stripslashes($row['message16']);
        
    $message17 stripslashes($row['message17']);
        
    // Build your formatted results here
        
    echo "<center><b>".$propertyname."</b></center>";
        echo 
    "<table width=100% border=0 cellspacing=0 cellpadding=0>";
        echo 
    '<tr>';
        echo 
    '<td width=20% valign=top><div class=titletxt>'.$row['category1'].'</div></td>';
        echo 
    '<td width=50% valign=top>'.$message1.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category2'].'</div></td>';
        echo 
    '<td valign=top>'.$message2.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category3'].'</div></td>';
        echo 
    '<td valign=top>'.$message3.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category4'].'</div></td>';
        echo 
    '<td valign=top>'.$message4.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category5'].'</div></td>';
        echo 
    '<td valign=top>'.$message5.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category6'].'</div></td>';
        echo 
    '<td valign=top>'.$message6.'</td><tr>';
        echo 
    '<tr><td colspan=4 valign=top></td></tr>';
        echo 
    '<tr><td width=14% valign=top><div class=titletxt>'.$row['category7'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message7.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category8'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message8.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category9'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message9.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category10'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message10.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category11'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message11.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category12'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message12.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category13'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message13.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category14'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message14.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category15'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message15.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category16'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message16.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category17'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message17.'</td></tr>';
        echo 
    '</table><br />';
        
    $parent_id $row['parent_id'];
    }

    if (
    mysql_affected_rows() == 0) {
        print 
    "No properties to be displayed.";
    }

    echo 
    "Click on the image to see the larger image.<br />";

    $query mysql_query("SELECT * FROM `ruralproperties_photos` WHERE `parent_id` = '$parent_id'") or die ("Could not query because: " mysql_error());
    while (
    $row mysql_fetch_array($query)) {
        echo 
    '<a href=# onClick="popWin(\''.$row['filename'].'.htm\', \'\', \'640\', \'480\')"><img src=http://www.houlahanyoung.com.au/images/'.$row['photos'].' border=0 /></a> ';
    }

    // Figure out the total number of results in DB:
    $total_results mysql_result(mysql_query("SELECT COUNT(*) AS Num FROM `ruralproperties`"),0) or die ("Could not query because: " mysql_error());

    // Figure out the total number of pages. Always round up using ceil()
    $total_pages ceil($total_results $max_results);

    // Build Page Number Hyperlinks
    echo "<center>";

    if (
    $page == 1) {
        echo 
    "Previous ";
    } else {
        echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=".($page-1)."\">Previous</a> ";
    }

    for(
    $i 1$i <= $total_pages$i++){
        if((
    $page) == $i){
            echo 
    "$i ";
            } else {
                echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
        }
    }

    if (
    $page == $total_pages) {
        echo 
    " Next";
    } else {
        echo 
    " <a href=\"".$_SERVER['PHP_SELF']."?page=".($page+1)."\">Next</a>";
    }

    echo 
    "</center>";
    mysql_close(); 
    Last edited by cturner01; Mar 20, 2007 at 19:05.

  2. #2
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I have got the photos to be displayed. Now I need to know how I can get them to be displayed to be matched for each property listing.

    Here is my updated code:
    PHP Code:
    require "config.php";
    if(!isset(
    $_GET['page'])) {
        
    $page 1;
    } else {
        
    $page $_GET['page'];
    }

    // Define the number of results per page
    $max_results 1;

    // Figure out the limit for the query based
    // on the current page number
    $from = (($page $max_results) - $max_results);

    // Perform MySQL query on only the current page number's results
    $sql mysql_query("SELECT * FROM `ruralproperties`, `ruralproperties_photos` LIMIT $from$max_results") or die ("Could not query because: " mysql_error());

    while(
    $row mysql_fetch_array($sql)){
        
    $image $row['photos'];
        
    $filename $row['photos'];
        
    $propertyname stripslashes($row['propertyname']);
        
    $message1 stripslashes($row['message1']);
        
    $message2 stripslashes($row['message2']);
        
    $message3 stripslashes($row['message3']);
        
    $message4 stripslashes($row['message4']);
        
    $message5 stripslashes($row['message5']);
        
    $message6 stripslashes($row['message6']);
        
    $message7 stripslashes($row['message7']);
        
    $message8 stripslashes($row['message8']);
        
    $message9 stripslashes($row['message9']);
        
    $message10 stripslashes($row['message10']);
        
    $message11 stripslashes($row['message11']);
        
    $message12 stripslashes($row['message12']);
        
    $message13 stripslashes($row['message13']);
        
    $message14 stripslashes($row['message14']);
        
    $message15 stripslashes($row['message15']);
        
    $message16 stripslashes($row['message16']);
        
    $message17 stripslashes($row['message17']);
        
    // Build your formatted results here
        
    echo "<center><b>".$propertyname."</b></center>";
        echo 
    "<table width=100% border=0 cellspacing=0 cellpadding=0>";
        echo 
    '<tr>';
        echo 
    '<td width=20% valign=top><div class=titletxt>'.$row['category1'].'</div></td>';
        echo 
    '<td width=50% valign=top>'.$message1.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category2'].'</div></td>';
        echo 
    '<td valign=top>'.$message2.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category3'].'</div></td>';
        echo 
    '<td valign=top>'.$message3.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category4'].'</div></td>';
        echo 
    '<td valign=top>'.$message4.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category5'].'</div></td>';
        echo 
    '<td valign=top>'.$message5.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category6'].'</div></td>';
        echo 
    '<td valign=top>'.$message6.'</td><tr>';
        echo 
    '<tr><td colspan=4 valign=top></td></tr>';
        echo 
    '<tr><td width=14% valign=top><div class=titletxt>'.$row['category7'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message7.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category8'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message8.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category9'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message9.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category10'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message10.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category11'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message11.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category12'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message12.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category13'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message13.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category14'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message14.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category15'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message15.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category16'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message16.'</td></tr>';
        echo 
    '<tr><td valign=top><div class=titletxt>'.$row['category17'].'</div></td>';
        echo 
    '<td colspan=3 valign=top>'.$message17.'</td></tr>';
        echo 
    '</table><br />';
        
    $parent_id $row['parent_id'];
    }

    if (
    mysql_affected_rows() == 0) {
        print 
    "No properties to be displayed.";
    }

    echo 
    "Click on the image to see the larger image.<br />";

    $query mysql_query("SELECT * FROM `ruralproperties_photos` WHERE `parent_id` = '$parent_id'") or die ("Could not query because: " mysql_error());
    while (
    $row mysql_fetch_array($query)) {
        echo 
    '<a href=# onClick="popWin(\''.$row['filename'].'.htm\', \'\', \'640\', \'480\')"><img src=http://www.houlahanyoung.com.au/images/'.$row['photos'].' border=0 /></a> ';
    }

    // Figure out the total number of results in DB:
    $total_results mysql_result(mysql_query("SELECT COUNT(*) AS Num FROM `ruralproperties`"),0) or die ("Could not query because: " mysql_error());

    // Figure out the total number of pages. Always round up using ceil()
    $total_pages ceil($total_results $max_results);

    // Build Page Number Hyperlinks
    echo "<center>";

    if (
    $page == 1) {
        echo 
    "Previous ";
    } else {
        echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=".($page-1)."\">Previous</a> ";
    }

    for(
    $i 1$i <= $total_pages$i++){
        if((
    $page) == $i){
            echo 
    "$i ";
            } else {
                echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
        }
    }

    if (
    $page == $total_pages) {
        echo 
    " Next";
    } else {
        echo 
    " <a href=\"".$_SERVER['PHP_SELF']."?page=".($page+1)."\">Next</a>";
    }

    echo 
    "</center>";
    mysql_close(); 


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
  •