Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignWeb Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old June 3rd, 2005, 02:06 AM
Kiwi_Dunc Kiwi_Dunc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Sydney Australia
Posts: 3 Kiwi_Dunc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 34 sec
Reputation Power: 0
Question Help with PHP script

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:
<?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);
 
?>

Reply With Quote
  #2  
Old June 4th, 2005, 02:56 PM
edwinbrains's Avatar
edwinbrains edwinbrains is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: UK
Posts: 160 edwinbrains User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 5 m 50 sec
Reputation Power: 5
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?

Reply With Quote
  #3  
Old June 5th, 2005, 07:07 PM
Kiwi_Dunc Kiwi_Dunc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Sydney Australia
Posts: 3 Kiwi_Dunc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 34 sec
Reputation Power: 0
Question Tags

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:
print <h1>There are $num_rows active Jobs."; 




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:
 ?>
 <FORM NAME="list" ACTION="" METHOD="GET">
 <INPUT TYPE="button" NAME="button" Value="View Job" onClick="testSelect(this.form)">
 <SELECT NAME="list" id={$row['FISJobNumber']}>
 
   <?php    
 
while ($row mysql_fetch_array($result))
 { 
 
 echo 
"\n<OPTION value='".$row['FISJobNumber']."'>{$row['FISJobNumber']}  {$row['JobTitle']}";
 }
 
 
mysql_close($link);
 
?>
       
 
 </SELECT>
 </FORM> 

Reply With Quote
  #4  
Old June 6th, 2005, 08:05 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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=>

Reply With Quote
  #5  
Old June 7th, 2005, 12:55 AM
Kiwi_Dunc Kiwi_Dunc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Sydney Australia
Posts: 3 Kiwi_Dunc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 34 sec
Reputation Power: 0
Question

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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignWeb Development > Help with PHP script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway