SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gallery cid Issue.

    i am trying to create a thumbnail for my gallery system i am making from ground up but at the moment when i go to cid=1 its fine shows everything with cid 1 but with cid=2 it shows cid 1 and 2 and 3

    heres my code

    PHP Code:
    <link href="billmayer.css" rel="stylesheet" type="text/css">
    <form method="post" action="">
    <input name="cid" type="hidden" value="<? echo $cid?>">
    </form>
    <?php
            $cid
    =($_GET['cid']);
            
    $imagethumbnail=$_POST['imagethumbnail'];
            if(
    $_GET['cid'])
                {
                
    $cid=($_GET['cid']);
                
    $imagethumbnail=$_POST['imagethumbnail'];
                
    $cid=$_GET['cid'];
                
    //$pid=$_GET['pid'];
                //echo $pid;
                
    include("dbconnect.php");
                
    $gQuery="SELECT * FROM gallery WHERE cid='$cid'";
                
    //excute the query
                //echo $gQuery;
                
    $rs=$con->query($gQuery);
                if(!
    $rs)
                {
                    
    $dbError="Error:Failed to executing query".mysqli_error($con);
                }
                else
                {
                    
    $count=$rs->num_rows;
                    if(
    $count>0)
                    {
                        
    print_r($data);
                        
    $data=$rs->fetch_assoc();
                        
    $imagethumbnail=$data['imagethumbnail'];
                    }
                    else
                    {
                        
    print_r($data);
                        echo 
    "<br/>Project Cannot be Found";
                    }
                }
            } 
                        
    $uQuery="SELECT * FROM gallery WHERE cid='$cid'"
                        
    $rs=mysqli_query($con,$uQuery); 
                        if(!
    $rs
                        { 
                            echo 
    "Error:".mysqli_error($con); 
                        } 
                        else 
                        { 
                            
    $count=$rs->num_rows
                            if(
    $count>0
                            { 
                                while(
    $data=$rs->fetch_assoc()) 
                                {
                                    echo 
    "<tr><td><img src=gallery/".$data['imagethumbnail']." width=\"100px\" height=\"100px\"></td></tr>";
                                }
                            } 
                        }
    ?>
    </div></div>
    Is there somthing i missed out on?

  2. #2
    SitePoint Addict
    Join Date
    Sep 2005
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look in your actual form to see if the hidden field really does have a value. You are using:
    <input name="cid" type="hidden" value="<? echo $cid?>">

    Because you are using $cid, you must be expecting Register Globals to be on which it probably is not. Substitute the following:
    <input name="cid" type="hidden" value="<? echo $_GET["cid"]; ?>">

    Also, you only need to set $cid one time in your script. You are setting it 3 separate times. Just set it at the top of your script:
    $cid = $_GET["cid"];

    Good luck with your project.
    PHP Shopping Cart Software Easy Ecommerce Shopping Cart Script.
    PHP Super Cart is 100% template driven.


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
  •