1.11M Members

send image from one page to display in another page

 
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..

 
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' message is perfect

 
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..

 
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?..

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: