mmarif4u Posted April 4, 2007 Share Posted April 4, 2007 Hi guys... I have a page where i have 3 pic buttons i store their names in sessions. Now for example i click the image name(1001), it goes to 2nd page where the session hold that pic name not other. 1- i want that a specific pic name go to the 2nd where it is stored in sessions. 2- I want to save that pic variable in the db. I mean just to store 1001 for that pic, not 1001.gif or something other. 1stpage.php <?php include ('session.php'); echo "<table align=\"center\" >"; echo "<tr>"; echo "<td align=\"center\" ><img src=\"images/logo1.jpg\"></img></td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" ><img src=\"images/home.gif\"></img></td>"; echo "</tr>"; echo "</table>"; echo "<table width=\"73.8%\">"; echo "<tr>"; echo "<td width=\"44.5%\"> </td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"{$_SESSION['1001']}\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"{$_SESSION['1006']}\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"{$_SESSION['1007']}\" border=\"0\"></img></a></td>"; echo "</tr>"; echo "</table>"; ?> 2ndpage.php <?php include ('session.php'); if ($_SESSION['1006'])){echo "<img src=\"images/1.jpg\">"; }else {} ?> session.php <?php Session_start(); $_SESSION['1001']="images/1001.gif"; $_SESSION['1006']="images/1006.gif"; $_SESSION['1007']="images/1007.gif"; ?> Any help will be appriciated... Thanks in advance. Quote Link to comment Share on other sites More sharing options...
joquius Posted April 4, 2007 Share Posted April 4, 2007 wouldn't it be easier to store the image numbers as an array, considering the fact that they contain no data? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted April 4, 2007 Author Share Posted April 4, 2007 How, r u have some idea... I think like this... $_SESSION['name'] = array(); Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted April 5, 2007 Author Share Posted April 5, 2007 Any idea guys... Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 5, 2007 Share Posted April 5, 2007 joquius's right an array would be the best route Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted April 5, 2007 Author Share Posted April 5, 2007 Yeh he is right. I use array but still no luck. Here is my code: $package=array('1001','1006','1007'); $package[0]="images/subscribe now.gif"; $package[1]="images/subscribe now.gif"; $package[2]="images/subscribe now.gif"; $_Session['1001']=$package[0]; $_Session['1006']=$package[1]; $_Session['1007']=$package[2]; In the next page i start like: session_start(); echo $session['1006']; But if click on any button it doesnot show me anything. it has to show me 1006.But nothing. Am i right... Quote Link to comment Share on other sites More sharing options...
fert Posted April 5, 2007 Share Posted April 5, 2007 it's $_SESSION not $_Session or $session Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted April 5, 2007 Author Share Posted April 5, 2007 Sorry for that i change it but still no luck. It driving me crazy,, I am setting for the last 3 hours for this but..... Quote Link to comment Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1001\"><img src=\"{$_SESSION['1001']}\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1006\"><img src=\"{$_SESSION['1006']}\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1007\"><img src=\"{$_SESSION['1007']}\" border=\"0\"></img></a></td>"; file : user.php $_GET['pic']; got selected image $_SESSION[$_GET['pic']]; Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted April 5, 2007 Author Share Posted April 5, 2007 This is recent update code : <?php session_start(); $_GET['pic']; $_SESSION[$_GET['pic']]; if ($_SESSION[$_GET['pic']]==$_SESSION['1006']){echo "<img src=\"images/1.jpg\">"; }else {} ?> 1stpage: <?php session_start(); $package=array('1001','1006','1007'); $package[0]="images/subscribe now.gif"; $package[1]="images/subscribe now.gif"; $package[2]="images/subscribe now.gif"; $_SESSION['1001']=$package[0]; $_SESSION['1006']=$package[1]; $_SESSION['1007']=$package[2]; echo "<table align=\"center\" >"; echo "<tr>"; echo "<td align=\"center\" ><img src=\"images/logo1.jpg\"></img></td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" ><img src=\"images/home.gif\"></img></td>"; echo "</tr>"; echo "</table>"; echo "<table width=\"73.8%\">"; echo "<tr>"; echo "<td width=\"44.5%\"> </td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1001\"><img src=\"{$_SESSION['1001']}\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1006\"><img src=\"{$_SESSION['1006']}\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1007\"><img src=\"{$_SESSION['1007']}\" border=\"0\"></img></a></td>"; /* echo "<td width=\"44.5%\"> </td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"images/subscribe now.gif\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"images/subscribe now.gif\" border=\"0\"></img></a></td>"; echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"images/subscribe now.gif\" border=\"0\"></img></a></td>"; */ echo "</tr>"; echo "</table>"; ?> <html><head><title>Subscribe Now</title></head> <body > </body> </html> But still no luck, now it show pic on every button clicked. Quote Link to comment Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 user.php if($_GET['pic'] == 1001){ echo "<img src="images/1.jpg>"; }else if($_GET['pic'] == 1006){ echo "<img src="images/2.jpg>"; } ........ ........... Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks u jitesh for ur time and help. I rearrange it and now working fine. <?php session_start(); include("include/db.php"); $_GET['pic']; $_SESSION[$_GET['pic']]; if($_GET['pic'] == 1006){$package='1006'; } if($_GET['pic'] == 1001){$package='1001'; } if($_GET['pic'] == 1007){$package='1007'; } $sql="insert into pack(package)values($package)"; $query= mysql_query($sql) or die( mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.