|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hi
I am new to PHP and what follows is one of my first scripts. Everything here works except I can not post to the next php form the value selected in the list option. Any ideas explained in newbie language, would be greatly appreciated. for obvious reasons I have removed my real db connections details. Regards Duncan PHP Code:
|
|
#2
|
||||
|
||||
|
Well you don't have </select> or </form> tags, and there's no submit button. Do you have these in the real form or not?
|
|
#3
|
|||
|
|||
|
The form and select tags are in both this example and the code I am using.
You can see the start for both tags in my example in the line that follows PHP Code:
I just did not copy enough code for you to see the end of the tags. Here is that sections I left out the top to save repartition. Regards Duncan PHP Code:
|
|
#4
|
||||
|
||||
|
Is there a reason you changed that button from submit, to a regular button?
Maybe your Javascript is causing an error. The ID in your <SELECT> is likely set to null... If you check your rendered HTML you're likely to see: <SELECT NAME="list" id=> |
|
#5
|
|||
|
|||
|
Sorry I posted an older version of the code by mistake that had a JavaScript thrown in, it was a previous attempt to solve my problem using Java.
I will repost the two pages completely The first page called fhq14.php runs a predefined query and displays the results as a list. Code:
<html>
Display all Jobs<head>
<link href="fhp1.css" rel="stylesheet" type="text/css">
<link href="menustyles.css" rel="stylesheet" type="text/css">
<SCRIPT >
</SCRIPT>
<style type="text/css">
<!--
.testcell {padding:1px;padding-right:20px;font-family:Courier New;}
.testtable {width:100%;}
</style>
<body>
<div id="mainwrap">
<div id="header">
<!-- Comment feild: This is where the Logo sits -->
<div id="logo">
<img src="logo[1].jpg" width="287" height="72">
</div>
</div>
<div id="nav_bar">
<!-- here is the set of drop down menus -->
<!--
<div id="menus">
<ul>
<li>Close Window
</ul>
</div>
</div>
<!--
<!-- Comment feild: This is Main Page sits -->
<div id="mainpage">
<div id="maincontentblock">
<?php
ini_set ('display_errors', 1); // this forces any errors to be displayed
// is a helpful prompt while I am learning
$db="db_name";
$link = mysql_connect("host","user","pwd");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT FISJobNumber, JobTitle, StaffName FROM tbljobs INNER JOIN tbllookupstaffname ON JobAssignedTo = record" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "<h1>There are $num_rows active Jobs.";
?>
<FORM NAME="list" ACTION="ViewDetails.php" METHOD="post">
<INPUT TYPE=SUBMIT NAME="list" Value="View Job Details" >
<SELECT NAME="list">
<?php
while ($row = mysql_fetch_array($result))
{
echo "\n<OPTION VALUE='".$row['FISJobNumber']."' >{$row['FISJobNumber']} {$row['JobTitle']}";
}
mysql_close($link);
?>
</SELECT>
</FORM>
</div>
</div>
</div>
</div>
</body>
</html>
</body>
</html>
The page it calls is "ViewDetails.php and its code is here. Code:
<html>
View Job Details<head>
<link href="fhp1.css" rel="stylesheet" type="text/css">
<link href="menustyles.css" rel="stylesheet" type="text/css">
<style type="text/css">
</style>
<body>
<div id="mainwrap">
<div id="header">
<!-- Comment feild: This is where the Logo sits -->
<div id="logo">
<img src="logo[1].jpg" width="287" height="72">
</div>
</div>
<div id="nav_bar">
<!-- here is the set of drop down menus -->
<!--
<div id="menus">
<ul>
<li>Close Window
</ul>
</div>
</div>
<!--
<!-- Comment feild: This is Main Page sits -->
<div id="mainpage">
<div id="maincontentblock">
<!-- Comment feild: This is where the content for the Main Info window is located -->
<?php
ini_set ('display_errors', 1); // this forces any errors to be displayed
// is a helpful prompt while I am learning
$db="db_name";
$link = mysql_connect("host","user","pwd");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
!isset ($_POST['list'])) {
echo $id;
$result = mysql_query( "SELECT FISJobNumber, JobTitle, DateCommenced, Name, Notes FROM tbljobs INNER JOIN tblcompnaydetails ON companyid = CompanyID WHERE FISJobNumber = $list";
or die("SELECT Error: ".mysql_error());
while ($row = mysql_fetch_array($result))
{
print "<h1>FIS Number -- {$row['FISJobNumber']}-- Job Title --{$row['JobTitle']}.";
print "<p>Date Job commenced --{$row['DateCommenced']}
;
print "<p>The Client is --{$row['Name']}
;
print "<p>Scope of the job
;
print "<p>{$row['Notes']}
;
print <p>Edit Details
\n";
}
}
mysql_close($link);
?>
</div>
</div>
</div>
</div>
</body>
</html>
</body>
</html>
Sorry about the confusion I hope this is not too much code to post. |
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Web Development > Help with PHP script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|