Jump to content

Issue with variable not updating


jamezz98
Go to solution Solved by jamezz98,

Recommended Posts

Hi all,

I am writing a simple time tracking web app in php with a backend mysql database to run on my NAS at home.  When entering time in to the timesheet i have a drop down for school then a drop down to location.  Once these are selected you select the date and enter the hours and click the submit button to add your time.  It does not seem to be passing the school ID correctly.  Here is the section from my main time entry page which select the school names from the School table and puts the id from the table in $school.

 

<td>
			<select id='schoolid' name="school"> 
			<option value="">-- Select School --</option> 
		
			<?php
					// Get records from database Locations 
				$list=mysql_query("select * from School order by school_name asc"); 

				// Show records by while loop in the drop down box. 
					while($row2=mysql_fetch_assoc($list)){
			?> 
					<option value=<? echo $row2['id']; ?>><? echo $row2['school_name']; ?></option>
					<?php $school = $row2['id']; ?>
			<?php }	?> 
			</select> 
		</td>

 

I have two hidden fields which store this information to pass to the post page.  I have even changed them from hidden to text as you can see below to see what they are being set to.  When i change school in the dropdown to another school it does not seem to change the id passed.


 </table>
	Mileage <input type="text" name="mileage" value=<?php echo $mileage_id; ?> />
	SchoolID <input type="text" name="school" value=<?php echo $school; ?> />
	<input type="submit" name="submit" value="Add Time" />
	
</form>

 

 

 

Is this enough information to see what i am doing wrong?

 

Thanks in advance

Regards

James

Link to comment
Share on other sites

  • Solution

Thanks for the response daviddannis.  I have been playing with it more today and worked out that i had removed the school_id field from my table therefore the insert was not working.  Once i had added this in the code works fine.

 

I left out the " in that string as the value was integer

 

Cheers

Link to comment
Share on other sites

jamezz98: You taught me me something new too. I thought that the html standards required quotes around all values. I looked it up and found out that they are just recommended.

By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ".

In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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