livepjam Posted September 24, 2006 Share Posted September 24, 2006 I saw the guidelines, but couldn't find the newbie section ??? so I was hoping someone could help me.Okay, here is what I am trying to accomplish. I have a template page made and I want to be able to pull from a MySQL database to output the page into the template. I've accomplished this already.I am using the $_SESSION['name'] variable to pull the information I want from my database. Now, on the page prior that is going to take me to the game.php page. When the user clicks on the link, I want to define the $_SESSION['name'] as the name I want to pull. I tried using javascript onclick like so, but I didn't have any luck.<a href="game.php" onclick="<?php $name="example 1"; $_SESSION['name']=$name; ?>">Example 1</a><a href="game.php" onclick="<?php $name="example 2"; $_SESSION['name']=$name; ?>">Example 2</a>I guess JS is client side and PHP is server side so I'm going about this all wrong. Can someone point me in the right direction? Thanks in advance. Link to comment Share on other sites More sharing options...
alpine Posted September 24, 2006 Share Posted September 24, 2006 Are you trying to use a html template ? Link to comment Share on other sites More sharing options...
livepjam Posted September 24, 2006 Author Share Posted September 24, 2006 Yeah. I am pulling from my database with PHP and outputting it into a HTML template. My goal is to reuse the same template so I don't have to create a different page for every item in the database.I would like to somehow define the $_SESSION variable as the item I would like to pull from the database. The problem I am having is I am using the same variable name and it always finds the 2nd one as it is the last one defined. I guess I am trying to figure out how I can use the same variable name, but only define it as what I am looking for if it is selected. Something along those lines. Or, is there some other way I can pass the variable to the next page when the link is clicked or possibly pass the variable name in the link? Link to comment Share on other sites More sharing options...
livepjam Posted September 24, 2006 Author Share Posted September 24, 2006 *bump* Link to comment Share on other sites More sharing options...
livepjam Posted September 25, 2006 Author Share Posted September 25, 2006 Nevermind. I figured it out. I didn't realize I could put it in the URL and use the $_GET function on the next page. Link to comment Share on other sites More sharing options...
Recommended Posts