0

guys! Im new in PHP and im developing a small website wherein there's many images on the page and when i click one of the image it must be shown into another page with full details.. but the problem when i click one of the image it shown's nothing! I tried to use $_SESSION[]; but I can't get the logic how to properly use it.. thnx.. please help..

7
Contributors
11
Replies
54
Views
3 Years
Discussion Span
Last Post by diafol
Featured Replies
0

Show some code, we need to know how you're trying to approach the problem. We need more details.

0
<?php 
//this is from image clicked from the previous page..
$_SESSION['image']=$_POST['image'];

echo $_SESSION['image']; 



?>

<img  src="images2/<?php echo $_SESSION['image'] ?>.jpg" width="300" height="250">    
0

if you already have the info you need in $_POST there is no reson to put it in a $_SESSION.
$_POST is usaly obtaind from a <FORM> on the first page or by an AJAX-request.
if you just want to send the image name to the 2 page why not use $_GET
on page 1

echo"<a href='page2.php?imageName=$imageName'>...</a>";

on page 2

$imageName=$_GET['imageName'];
0

"pzuurveen"

yeah.. thnx its running well but it shows nothing, i think there's something wrong with my code.. please check:

Page1.php:

    $query = "SELECT * FROM cfashion_mens";

    $result = mysql_query($query) or die(mysql_error());

        while($row = mysql_fetch_array($result)){
            $image = $row["image"];
            $img_name = $row["img_name"];
            $price = $row["price"];

            ?>
            <?php 
            echo'<table>';
            echo '<tr><td>';?>
            <img   style = "width:250px; height:250px;" title=" <?php echo $img_name ?>" src = "<?php echo $image; ?> "  /><?php echo '</td></tr>';?>


              **  //I try to use your code here:***
                //echo"<a href='page2.php?image=$image'>...</a>";**


            <?php

            echo '<tr><td align="center">' . $img_name . ' == £' .  $price . '</td></tr>' ;

            echo '</table>';
        }

Page2.php

$imageName=$_GET['image'];

Page1.php is running well but when i click one of the images in the page.. then it shows nothing into page2.php..

Edited by markii.borabon: checking

0

Did you echo $imageName=$_GET['image']; on page2.php ?

please show your page2 codes ...

0

"Bachov Varghese"

im done with that problem "Bachov Varghese" I change my code into this:

"page1.php"

    /* selected table*/
    $query = "SELECT * FROM cfashion_mens";

    $result = mysql_query($query) or die(mysql_error());

        while($row = mysql_fetch_array($result)){
            $image = $row["image"];
            $img_name = $row["img_name"];
            $price = $row["price"];

    <a href="SalesPage2.php?ref=<?php echo $image; ?>">

<?php
        ?><img src = "<?php echo $image; ?> "/>;
<?php
        echo $img_name .  $price ;
}       
        echo '</table>';
?>

"page2.php"

    <img src = "<?php echo $_GET['ref'] ?>"  />;

my problem now is... I want to get all the details of each image from page1.php down here to page2.php.. but suddenly only image is shown.. please help.. thnx

0

$image = $row["image"]; is $row["image"] the url to the image?

after that you start messing up php and html code

0

$row["image"] is a row from my database.. also $row["img_name"] and $row["price"].. I actually done sending the image from page1.php to page2.php but the other details like price and img_name.. dsn't shown on page2.php what's the best thing to do?..

-1

I want to show single image from one page to another page in php. In first i have multiple picture from database using path. But i want to show one image on another page when user click on particular image from page one. When user click on first page image it will automatically move to second page and display that image.

Edited by pritaeas: Removed spam link.

1

Start your own thread as this may be a slightly different take on the OP.

Votes + Comments
It smells like a spammy post to me :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.