Page 1 of 1
Trying to select just the product I click on for next page
Posted: Fri Feb 06, 2004 5:38 am
by nutstretch
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
Posted: Fri Feb 06, 2004 5:40 am
by twigletmac
You are trying to get the value of style from the URL? If that's so then you need to use $_GET['id'] not $style.
Mac
Posted: Fri Feb 06, 2004 5:54 am
by nutstretch
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!!!
Posted: Fri Feb 06, 2004 6:00 am
by Straterra
What version of PHP are you running?
Posted: Fri Feb 06, 2004 6:06 am
by nutstretch
PHP4
Posted: Fri Feb 06, 2004 6:07 am
by twigletmac
PHP 4 what? There's a massive difference between 4.0 and 4.1 and up.
Mac
Posted: Fri Feb 06, 2004 6:11 am
by JayBird
You are using an old version of PHP:
Code: Select all
$sql = "SELECT * FROM tblShoes where StyleID like '".$HTTP_GET_VARS['id']."'";
$resultID = mysql_query($sql, $linkID);
Mark
Posted: Fri Feb 06, 2004 6:31 am
by mahara
Straterra wrote:What version of PHP are you running?
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.
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'];
}
Hope helps.

Posted: Fri Feb 06, 2004 6:43 am
by nutstretch
many thanks. If I upgrade do I have to uninsally what I have and reconfigure. I seem to remember getting very confused when i set it up lol.

Posted: Fri Feb 06, 2004 7:01 am
by mahara
If you prefer to upgrade, you can read how configure your server and you PHP in 'install.txt' that included in the PHP distro files. Check it up and see how easy to install PHP.
Remember to restart your server after finishing the installation.
Hope helps.