theHussle theHussle - 1 year ago 67
MySQL Question

using a href to pass value for $_GET[] not working

I was using GET on a webpage to handle applying filters to a MYSQL query which displayed items from a database, the information was then displayed in a div and at the bottom of the div I had this.

<a href="tyreDetails.php?id=<?php echo $product["recid"]; ?>">
<button class="btn btn-default btn-sm btn-primary">Details</button>

This was then used on another page. To display the information again using the id of the item.

if (isset($_GET['id'])) {

$id = mysqli_escape_string($db, $_GET['id']);

$featuredSql = "SELECT t.*, s.quantity, s.rrp AS nRetailPrice, AS city_name, ts.thumbnail as tread_thumbnail, ts.bigpic as tread_bigpic, t.rating FROM tyres t INNER JOIN stocklevels s

ON t.stockcode=s.stockcode LEFT JOIN tyre_treads ts ON t.treadid=ts.recid LEFT JOIN reseller r ON WHERE s.quantity>0 AND s.rrp>0 ";

// $featuredResult = mysqli_query($db, $featuredSql);

if ($id != 'Any' && $id != null) $featuredSql .= " AND t.recid='$id' LIMIT 1";

if (!$featured = mysqli_query($db, $featuredSql)) die(mysqli_error());
if (!$tyre1 = mysqli_fetch_object($featured)) echo "<br />No tyres match those parameters. Please try again.";

$row = mysqli_fetch_array($featured, MYSQLI_NUM);

$read = $row[1];

I changed a form on the first page from using GET to using POST, now I get a 500 error from the server. The url looks like, so the value is being passed across.

I'm not sure why this no longer works? It worked fine until I changed the original search area to post, but this is separated and isn't attached to a form at all.

I just reverted all the changes of the other form to post and it is still no longer working. I now assume that is not the problem.

Answer Source
<a href="tyreDetails.php?id=<?php echo $product["recid"]; ?>">

is a hyperlink so it wont be of "POST" type anyways.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download