Jump to content

[SOLVED] loosing value when page reloads?


shadiadiph

Recommended Posts

Hi I keep loosing the value $adid when the page reloads. I am trying to get it so that if the user changes the category they can select a new one  but when Ia select and the page reloads I loose the value $adid

in the line that says    $sql = "select * from tblproddetails where intProductID=$adid"; ???

 

<? 
session_start();
error_reporting(7);
require("../global/admin_functions.php");
$adid  = ($_POST["adid"]);
$sid = $_SESSION['LOGINID'];
if($sid!="")

{
$sql 	= "select * from tblproddetails where intProductID=$adid";
$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;
self.location='updatead.php?cat=' + val ;
}
function disableselect()
{
<?
if(isset($cat) and strlen($cat) > 0){
echo "document.postad.subcat.disabled = false;";}
else{echo "document.postad.subcat.disabled = true;";}
?>
}
//-->

</script>

</head>

<body onload=disableselect();>
<div id="wrapper">

	 <div id="content">

      
<table class="postad">
<form name="postad" method="post" action="updatedad.php" onsubmit="return v.exec()">
<input type="hidden" name="adid" value="$adid" />
<tr><td><h1>EDIT AD Ref <?=$id?></h1></td></tr>
<tr><td>
<table class="postadmain">
<tr><td>&nbsp</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"); } 


echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>$category</option>";
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>

<tr><td> </td></tr>
<tr><td><input class="button" type="submit" name="submit" value="Submit Ad" /></td></tr>
</form>
<tr><td colspan="2" class="double">&nbsp</td></tr>
</table>
</td>
</tr>	      	
</table>

          		 

	 </div>

   </div>

  
   
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/138673-solved-loosing-value-when-page-reloads/
Share on other sites

I have figured out it is this part that really needs to carry the value over but conventional methods seem to stop the script from working?

 

self.location='updatead.php?cat=' + val ;

 

I have tried self.location='updatead.php?adid=$adid&cat=' + val ;

 

but it doesn't carry the value?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.