Trying to select just the product I click on for next page
Moderator: General Moderators
-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester
Trying to select just the product I click on for next page
I have a page which returns the results of a search and have added a link on the image displayed. I want this link to open another page where more info on that product is displayed. below is the code for the link and image.
print "<td><a href = 'search.php?id=$style'><img src='$test' width='128' height='85' alt='Click here to see more info on this shoe'></a></td>";
I have tested and the id works on this page.
I need to carry that ID over to the next page so do another query just on that ID.
How do I get that id to go across ? I have tried this:
$resultID = mysql_query("SELECT * FROM tblShoes where StyleID like '$style'", $linkID);
... but get told undefinded variable style
Am I supposed to declare and populate earlier or have I left some code out ?
Any help appreciated
print "<td><a href = 'search.php?id=$style'><img src='$test' width='128' height='85' alt='Click here to see more info on this shoe'></a></td>";
I have tested and the id works on this page.
I need to carry that ID over to the next page so do another query just on that ID.
How do I get that id to go across ? I have tried this:
$resultID = mysql_query("SELECT * FROM tblShoes where StyleID like '$style'", $linkID);
... but get told undefinded variable style
Am I supposed to declare and populate earlier or have I left some code out ?
Any help appreciated
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester
I tried this: $style = $_GET['id']; and it didn't work.
I got
Warning: Undefined variable: _GET in c:\program files\apache group\apache\htdocs\newwebsite\search.php on line 51
i also tried this: $resultID = mysql_query("SELECT * FROM tblShoes where StyleID like '$_GET['id']'", $linkID);
and got this error
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\newwebsite\search.php on line 52
i am feeling really thick today sorry!!!
I got
Warning: Undefined variable: _GET in c:\program files\apache group\apache\htdocs\newwebsite\search.php on line 51
i also tried this: $resultID = mysql_query("SELECT * FROM tblShoes where StyleID like '$_GET['id']'", $linkID);
and got this error
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\newwebsite\search.php on line 52
i am feeling really thick today sorry!!!
-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You are using an old version of PHP:
Mark
Code: Select all
$sql = "SELECT * FROM tblShoes where StyleID like '".$HTTP_GET_VARS['id']."'";
$resultID = mysql_query($sql, $linkID);-
mahara
- Forum Commoner
- Posts: 37
- Joined: Wed Nov 13, 2002 1:08 am
- Location: Bandung, Jawa Barat, Indonesia
According to statement above, your version of PHP may haven't supported yet superglobals variables starts with '$_' (eg: $_GET, $_POST, etc.) especially if you are running version below 4.1.0. Try to upgrade to 4.1.0 or later (eg: 4.3.4) first if you want to use those type of variables.Straterra wrote:What version of PHP are you running?
However, if you don't want to, you still can use '$HTTP_GET_VARS' or '$HTTP_POST_VARS'. But remember if you enclose this variable(s) within a function, you should globalize the variable(s) first using 'global' keyword.
Code: Select all
function whatever()
{
global $HTTP_GET_VARS;
$style = $HTTP_GET_VARSї'id'];
}-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester