[SOLVED] Passing variables to other pages in a link
Posted: Mon Apr 04, 2005 12:17 pm
I want to put band names out of my database inside links and loop it through to display a set of links of all the bands in my database, this bit works no problem.
I then want to be able to click those links, go to a seperate page and on that page get up the band details, to do this I need to pass the band name to the page the link is going to. I thought I could do this using $_GET but it hasn't worked, the code is below.
Here is the code ont he first page.
Here is the script for the second page, I'm just echoing out the variable to test see if it works, once I've done this I can put it into a select query and get all the information I need:
I then want to be able to click those links, go to a seperate page and on that page get up the band details, to do this I need to pass the band name to the page the link is going to. I thought I could do this using $_GET but it hasn't worked, the code is below.
Here is the code ont he first page.
Code: Select all
$query="SELECT * FROM band";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num)
{
$band=mysql_result($result,$i,"band_name");
//Link here, shows up no problem
echo'<a href="bandview.php?band=$band">'.$band; echo'</a>';
i++;
}Code: Select all
include('connect.inc');
$band = $_GET['bandname'];
echo .$band;