Results 1 to 3 of 3

Thread: Select From Statement

  1. #1
    Join Date
    Aug 2009
    Location
    Florida
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Select From Statement

    Working on a photo album that displays pictures by the month and year. The month and year is passed tru the url to the album. I'm not sure what I'm doing wrong here but I'm not getting any results... Any Help would be appreciated......


    PHP Code:

    <?
    $pmonth
    $_GET["pmonth"];
    $pyear$_GET["pyear"];


    $submit=fn;
    $order_type=fn;
    if (!
    $ByPage$ByPage=8;
    if (!
    $Start$Start=0;
    // Set how wide you want your table
    $tblWidth 4;
    [
    COLOR="Red"]////////// I think this is where my problem is [/COLOR]
    $sql mysql_query("select * from photo_album where pmonth = \"$pday\" and pyear = \"$pyear\" limit $Start,$ByPage");
    $i 1;
    echo 
    '<table align=center>';
    // Check to see if any results were returned
    if(mysql_num_rows($sql) > 0){
        echo 
    '<tr>';
        
    // Loop through the results
        
    while($row mysql_fetch_array($sql)){
            echo 
    '<td><a rel="example_group" href="images/'$row['fn'] .'" title="'$row['title'] .' <br> Date: '$row['date'] .'  <br>'$row['disc'] .'"><img src="images/'$row['fn'] .'" width="120" height="100"  /></a><br><br><center><a href="javascript:ajaxpagefetcher.load(\'demo\', \'see_comments.php?fn='$row['fn'] .'\', false)">'$row['rp'] .'<img src="icons/comments.png" width="16" height="16" title="See Comments" border="0"/></a>&nbsp;&nbsp;&nbsp;<a href="post_comment.php?fn='$row['fn'] .'" onclick="PostComment(this.href,\'name\',\'475\',\'300\',\'No\');return false"><img src="icons/post.png" width="16" height="16" title="Post Comment" border="0"/></a>
    </td>'
    ;
            if(
    $i == $tblWidth){
                echo 
    '</tr><tr>';
                
    $i 0;
            }
            
    $i++;
        }
        echo 
    '</tr>';
    }else{
        echo 
    '<tr><td>No Pictures Posted Yet!<br><br><a class=TNA href="admin/admin_album.php">Click Here</a> to upload pictures.</td></tr>';
    }
    echo 
    '</table>';
    $cp "select count(fn) from photo_album";
    $rcp mysql_query($cp) or die (mysql_error());
    $ap mysql_fetch_array($rcp);
    $a $ap[0];

    echo 
    "<table width=500 align=center cellspacing=0><tr>";

    if (
    $a <= $ByPage && $Start == '0')
    {

    }

    elseif (
    $a $Start $ByPage && $Start $ByPage >= $a || $Start == )
    {
        
    $nom $Start $ByPage;
        echo 
    "<td align=right><a class=TNA href=\"album.php?submit=$submit&order_type=$order_type&Start=$nom\">Next Page <img src=\"icons/next.gif\" width=\"16\" height=\"16\" alt=\"Next Page\" border=\"0\"/></a></td>";
    }
    elseif ( (
    $Start $a && $Start $ByPage) || ($Start $ByPage >= $a))
    {
        
    $nom1 $Start $ByPage;
        echo 
    "<td align=left><a class=TNA href=\"album.php?submit=$submit&order_type=$order_type&Start=$nom1\"><img src=\"icons/back.gif\" width=\"16\" height=\"16\" alt=\"Next Page\" border=\"0\"/> Back</a></td>";
    }
    else
    {
        
    $nom1 $Start $ByPage;
        echo 
    "<td align=left><a class=TNA href=\"album.php?submit=$submit&order_type=$order_type&Start=$nom1\">previous</a></td>";
        
    $nom $Start $ByPage;
        echo 
    "<td align=right><a class=TNA href=\"album.php?submit=$submit&order_type=$order_type&Start=$nom\">next</a></td>";
    }

    echo 
    "</tr></table>";

    exit;



    ?>

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Looks like you're just using the wrong variable name:

    PHP Code:
    $sql mysql_query("select * from photo_album where pmonth = \"$pday\" and pyear = \"$pyear\" limit $Start,$ByPage"); 
    You're using $pday, instead of $pmonth. Try changing that and see what happens.

    PHP Code:
    $sql mysql_query("select * from photo_album where pmonth = \"$pmonth\" and pyear = \"$pyear\" limit $Start,$ByPage"); 

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    captainjustin (01-09-2011)

  4. #3
    Join Date
    Aug 2009
    Location
    Florida
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    That was it..... I knew it hat to be some silly mistake.... Need to stop trying to write code at 2am..... Thanks

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
  •