Jump to content

passing page query result in another page query


blueinc

Recommended Posts

In my first page I have I have a query that returns tournaments names in a table in this format

echo "<td><a href='tournament.php'>" . $info['tournament'] . "</a></td>";

$info['tournament'] has the tournament name which when clicked takes me to the page tournament.php where I have this code

$data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='';") or die(mysql_error());

what i want is to have the value clicked in the previous page that linked to this one, in tournament='HERE' so that the query retrieve the data for that tournament

 

i have tried 

echo "<td><a href='tournament.php?tournament=".$info['tournament']."'>" . $info['tournament'] . "</a></td>";

and 

$tournamentName = $_GET['tournament'];
$data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='$tournamentName';") or die(mysql_error());

the query returns empty and when i print $tournamentName i get for example (Golden Cup) which should be (Golden Cup #1) 

the $_GET removed #1 which is why the query returns NULL and if i do partial match to $tournamentName i will get all the Golden Cup tournaments not just the one i clicked 

 

can anyone help me solve this problem ?

 

Thank you

Link to comment
Share on other sites

The code that you are using should work with ID's. I highly recommend using this for any type of match. If you don't already have an ID associated with tournaments, use auto increment when creating it.

echo "<td><a href='tournament.php?id=".$info['id']."'>" . $info['tournament'] . "</a></td>";
$tournamentId = $_GET['id'];
$data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='$tournamentId' LIMIT 1;") or die(mysql_error());
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.