saving parameters
Posted: Fri Dec 03, 2010 10:00 am
I have one page that passes a parameter to another page. For example
http://mydomain.com/view_jobs_custwiths ... ?cust_id=1
Once I get to the new page I have two forms. One displays the data from my database based on the parameter I sent it. The other is a form that I want the user to reset within the existing selected data. Here is my code. The problem is once I display the screen and then enter search criteria it loses the cust_id value and my query fails and returns no data. I have tried using "$_GET" on the cust_id, saving it to a session variable, but I must be missing something.
http://mydomain.com/view_jobs_custwiths ... ?cust_id=1
Once I get to the new page I have two forms. One displays the data from my database based on the parameter I sent it. The other is a form that I want the user to reset within the existing selected data. Here is my code. The problem is once I display the screen and then enter search criteria it loses the cust_id value and my query fails and returns no data. I have tried using "$_GET" on the cust_id, saving it to a session variable, but I must be missing something.
Code: Select all
<form name="search" method="post" action="<?=$PHP_SELF?>">
<b>Seach for:</b> <input type="text" name="find" value='<?php echo $find; ?>'/> <b>in</b>
<Select NAME="field">
<Option VALUE="job_nm" <?php if($_POST['field'] == "job_nm"): ?>selected='selected'<?php endif;?>>Job Name</option>
<Option VALUE="job_num" <?php if($_POST['field'] == "job_num"): ?>selected='selected'<?php endif;?>>Job Number</option>
<Option VALUE="insp_nm" <?php if($_POST['field'] == "insp_nm"): ?>selected='selected'<?php endif;?>>Inspector</option>
<Option VALUE="wo_num" <?php if($_POST['field'] == "wo_num"): ?>selected='selected'<?php endif;?>>Work Order</option>
<Option VALUE="wo_status" <?php if($_POST['field'] == "wo_status"): ?>selected='selected'<?php endif;?>>WO Status</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<p>Work status is Active, Scheduled, Complete, or Cancelled</p>
<p></p>
<?php
include ("dbconnect.inc.php");
$cquery = mysql_query("select * from customer where cust_id = $cust_id");
$crow = mysql_fetch_object($cquery);
$cnm = $crow->cust_nm;
echo "<h2>Jobs/Work Orders for Customer: <strong>$cust_id - $cnm</strong> </h2>";
if ($searching =="yes" and !$find == "") {
//Now we search for our search term, in the field the user specified
$query = mysql_query("Select * from work_orders, jobs, inspector where wo_cust_id = [b]$cust_id[/b] and wo_insp_id = insp_id and wo_job_id = job_id and upper($field) LIKE '%$find%' order by wo_num");
}
else
{
$query = mysql_query("Select * from work_orders, jobs, inspector where wo_cust_id = [b]$cust_id[/b] and wo_insp_id = insp_id and wo_job_id = job_id order by wo_num");
}
?>
<form name="jobsforcust" method = "post" action="post">