0

Dear Experts,

I'm newbie in php. Can anyone please help to check my code as below: Blank value inserted to Mysql using dropdownbox. Thanks in advance.

<?php
mysql_connect("localhost","root","") or die("Error: ".mysqlerror());
mysql_select_db("project_Test");
 
$Serial_Number = $_GET['Serial_Number'];
$sql = "select * from `TestTable` where Serial_Number = $Serial_Number";
$query = mysql_query($sql);

$row = mysql_fetch_array($query);
	$Serial_Number = $row['Serial_Number'];
    $Customer = $row['Customer'];
    $Date = $row['Date'];
    $Model = $row['Model'];

$result = mysql_query("SELECT * FROM Customer");
?>
<html>
<head>
<title>Edit User Info</title>
</head>
 
<body>
 
<form action="updateinfo.php" method="post">
 
Serial Number:<br/>
<input type="int" value="<?php echo $row['Serial_Number'];?>" name="Serial Number" />
 
<br/>
 
Customer:<br/><Select name='access'>
<?php
while ($row = mysql_fetch_array($result)) {
?>
<option value="<?php echo $row['Customer']; ?>" <?php if ($Customer == $row['Customer']) { echo 'selected'; } ?> ><?php echo $row['Customer']; ?></option>
<?php } ?>
</select>
<br/>
 
Date:<br/>
<input type="date" value="<?php echo $Date;?>" name="Date"/>
 
<br/>
 
Model:<br/>
<input type="varchar" value="<?php echo $Model;?>" name="Model"/>
 
</br>
 
<input type="submit" value="submit changes"/>
</form>
</body>
</html>
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Davetew
0

Hi Veedeoo,

Thank you for the prompted response. I solve the problem by changing

Customer:<br/><Select name='access'>

to

Customer:<br/><Select name='Customer'>

Thank you and Regards,
Dave

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.