Select a single job number rather than just the last
Posted: Wed Aug 12, 2009 3:43 am
Hi Guys,
I am working on a job page that uses an sql query to get details of all today's jobs, this then places them all onto a page, then when I click the button under each individual job it passes that value from a (will be but not currently for bugging purposes) hidden text box and passes that value onto a new page to get all details for that particular job.
The problem I am having is that when I click on a button, it automatically passes the last job through, no matter which job I click on (and I know the job no is in the text boxes as I can see them laid out correctly, this is driving me nuts,
I have tried BOTH The post and get methods and a mixture of the two but it always does the same thing, continually passes through the last job number
I will post the code below for the sending page and the receiving page.
First page
Receiving page
Many thanks guys a big gold star for anyone who can fix this for me
I am working on a job page that uses an sql query to get details of all today's jobs, this then places them all onto a page, then when I click the button under each individual job it passes that value from a (will be but not currently for bugging purposes) hidden text box and passes that value onto a new page to get all details for that particular job.
The problem I am having is that when I click on a button, it automatically passes the last job through, no matter which job I click on (and I know the job no is in the text boxes as I can see them laid out correctly, this is driving me nuts,
I have tried BOTH The post and get methods and a mixture of the two but it always does the same thing, continually passes through the last job number
I will post the code below for the sending page and the receiving page.
First page
Code: Select all
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>
<body>
<form action="GetSingleJob.php" name="GetJobDets" method="POST">
<?php
$database_name="";
$database_password="";
$database_host="";
$Username="";
$conn = @mysql_connect($database_host, $Username, $database_password, $database_name) or die(mysql_error());
echo "<html><head><title>All Jobs</title></head><body>";
echo "<h1>All Jobs</h1>";
$sql = "SELECT * FROM Jobs where Print_Complete=0 and JobNo like '%EB%'";
$results=mysql_db_query($database_name,$sql,$conn);
while ($output=mysql_fetch_array($results)) {
$JobNo =$output[JobNo];
echo "<p><b>Job ID:</b> ". $output[JobNo];
echo "<br /><b>Desc:</b> ". $output[Job_Desc];
echo "<br /><b>Print Date:</b> ". $output[Print_Date];
echo "<br /><b>Delivery Date:</b> ". $output[Delivery_Date];
echo "<br />";
echo("<INPUT TYPE=\"text\" NAME=\"JobNumber\" VALUE= \"$JobNo\" id='JobNumber'>");
echo("<INPUT TYPE=\"submit\" NAME=\"ViewJob\" VALUE=\"View Job\">");
$JobNo="";
echo "<hr /></p>";}
mysql_close($conn);
?>
</form>
<INPUT TYPE=BUTTON NAME='ViewTodaysJobs' VALUE='View Todays Jobs' onClick="window.location='selectatodaysjobs.php'">
<INPUT TYPE=BUTTON NAME='ViewALLJobs' VALUE='Refresh Jobs' onClick="window.location='selectalljobs.php'">
</body>
</html>
Code: Select all
<?php
$database_name="";
$database_password="";
$database_host="";
$Username="";
$conn = @mysql_connect($database_host, $Username, $database_password, $database_name) or die(mysql_error());
$JobNo = $_POST['JobNumber'];
//This receives the JobNo data from the hidden field on the previous page
$sql = "SELECT * FROM Jobs where JobNo='$JobNo'";
$results=mysql_db_query($database_name,$sql,$conn);
echo "<html><head><title>Job No: $JobNo</title></head><body>";
echo "<h1>Job No: $JobNo </h1>";
while ($output=mysql_fetch_array($results)) {
$JobNo =$output[JobNo];
echo "<p><b>Job ID:</b> ". $output[JobNo];
echo "<br /><b>Date Added:</b> ". $output[Date_Added];
echo "<br /><b>Company Name:</b> ". $output[Company_Name];
echo "<br /><b>Desc:</b> ". $output[Job_Desc];
echo "<br /><b>Press:</b> ". $output[Press];
echo "<br /><b>Print Date:</b> ". $output[Print_Date];
echo "<br /><b>Delivery Date:</b> ". $output[Delivery_Date];
echo "<br />";
echo("<INPUT TYPE=text NAME='Job' VALUE= $JobNo>");
echo "<hr /></p>";
}
mysql_close($conn);
?>
<INPUT TYPE=BUTTON NAME='ViewALLJobs' VALUE='View ALL Jobs' onClick="window.location='selectalljobs.php'">
<INPUT TYPE=BUTTON NAME='ViewTodaysJobs' VALUE='Todays jobs' onClick="window.location='selectatodaysjobs.php'">
<INPUT TYPE=BUTTON NAME='Complete' VALUE='Job Complete' onClick="window.location='selectalljobs.php'">
</form>