I keep loosing the value $adid when the page reloads the form which leaves
$sql = "select * from tblproddetails where intProductID=$adid";
without a value the problem seems to be in this line
self.location='updatead.php?cat=' + val ;
even if i put updated.php?adid=$adid&cat it doesn't work is there another way to to this?
here is the full code which is relevant with the important parts highlighted.
<?
session_start();
error_reporting(7);
require("../global/admin_functions.php");
[COLOR="red"]$adid = ($_POST["adid"]);[/COLOR] [COLOR="DarkOrange"]//this is where the page initially gets $adid from which is carried from the previous page//[/COLOR]
$sid = $_SESSION['LOGINID'];
if($sid!="")
{
[COLOR="red"] $sql = "select * from tblproddetails where intProductID=$adid";[/COLOR]
$temps = $DB_site->query($sql);
if($row=$DB_site->fetch_array($temps))
{
$id = $row["intProductID"];
$accountid = $row["intAccountID"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$title = $row["title"];
$description = $row["description"];
$minorder = $row["minorder"];
$unitprice = $row["unitprice"];
$currency = $row["currency"];
$countrylocation = $row["countrylocation"];
$created = $row["dtCreated"];
}
}
else
{
header ("location: ../../invalid.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>H & M Trading</title>
<link rel="stylesheet" type="text/css" href="../user.css" />
<script language="JavaScript" src="../../validator.js"></script>
<SCRIPT language=JavaScript>
<!--
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
[COLOR="red"]self.location='updatead.php?cat=' + val ;[/COLOR]
}
function disableselect()
{
<?
if(isset($cat) and strlen($cat) > 0){
echo "document.postad.subcat.disabled = false;";}
else{echo "document.postad.subcat.disabled = true;";}
?>
}
//-->
</script>
</head>
[COLOR="Red"]<body onload=disableselect();>[/COLOR]
<div id="wrapper">
<div id="content">
<table class="postad">
<form name="postad" method="post" action="updatedad.php" onsubmit="return v.exec()">
<tr><td><h1>EDIT AD Ref <?=$id?></h1></td></tr>
<tr><td>
<table class="postadmain">
<tr><td> </td></tr>
<tr><td><span id="t_cat">CATEGORY</span></td></tr>
<tr><td>
<?
$quer2=mysql_query("SELECT DISTINCT category,intCatID FROM tblcatdetails order by category");
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT subcategory FROM tblsubcatdetails where intCatID=$cat order by subcategory");
}else{$quer=mysql_query("SELECT DISTINCT subcategory FROM tblsubcatdetails order by subcategory"); }
[COLOR="Red"]echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>$category</option>";[/COLOR]
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['intCatID']==@$cat){echo "<option selected value='$noticia2[category]'>$noticia2[category]</option>"."<BR>";}
else{echo "<option value='$noticia2[intCatID]'>$noticia2[category]</option>";}
}
echo "</select>";
?>
</td></tr>
<tr><td><span id="t_subcat">SUB CATEGORY</span></td></tr>
<tr><td>
<?
echo "<select name='subcat'><option value=''>$subcategory</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>";
}
echo "</select>";
;
?>
</td></tr>
Any ideas?