1,105,391 Community Members

send image from one page to display in another page

Member Avatar
markii.borabon
Newbie Poster
12 posts since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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..

Member Avatar
bops
Posting Whiz
301 posts since Aug 2005
Reputation Points: 1 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
markii.borabon
Newbie Poster
12 posts since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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">    
Member Avatar
pzuurveen
Posting Pro in Training
440 posts since Sep 2006
Reputation Points: 48 [?]
Q&As Helped to Solve: 91 [?]
Skill Endorsements: 5 [?]
 
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'];
Member Avatar
anas.man
Newbie Poster
18 posts since Dec 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

'pzuurveen' message is perfect

Member Avatar
markii.borabon
Newbie Poster
12 posts since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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..

Member Avatar
Bachov Varghese
Posting Whiz in Training
205 posts since Sep 2011
Reputation Points: 45 [?]
Q&As Helped to Solve: 52 [?]
Skill Endorsements: 6 [?]
 
0
 

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

please show your page2 codes ...

Member Avatar
markii.borabon
Newbie Poster
12 posts since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
pzuurveen
Posting Pro in Training
440 posts since Sep 2006
Reputation Points: 48 [?]
Q&As Helped to Solve: 91 [?]
Skill Endorsements: 5 [?]
 
0
 

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

after that you start messing up php and html code

Member Avatar
markii.borabon
Newbie Poster
12 posts since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: