hey i have a javascript datepicker working on my site but when i try to store the data on mysql im having trouble setting the primary key from the parent table into a new id_item. i pass the id in the url eg
somepage.php?id=1
it still doesnt store the date from the datepicker because of the date format
eg yyyyddmm, mmddyyyy, ect
here i pass the id from the previous page
<td align="centre"><a href="prices.php?id=<? echo $rows['id']; ?>">prices</a></td>
here i load prices to select a new date and store a price
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// get value of id that sent from address bar
$id=$_POST['id'];
$id=$id_item;
// Retrieve data from database
$sql="SELECT * FROM $tbl_name WHERE id='$id_item'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?>
<html>
<head>
<script language="javascript" type="text/javascript" src="datetimepicker_css.js">
</script>
</head>
<body>
<form name="price" method="post" action="update_prices.php">
<label for="date_start">Date start>> </label>
<input name="date_start" type="text" id="date_start" maxlength="25" size="25"/>
<img src="images/cal.gif" onclick="javascript:NewCssCal('date_start')" style="cursor:pointer"/>
<br>
<label for="date_end">date end >> </label>
<input name="date_end" type="text" id="date_end" maxlength="25" size="25"/>
<img src="images/cal.gif" onclick="javascript:NewCssCal('date_end')" style="cursor:pointer"/>
<br>
price <textarea name="price" rows="1" cols="40" wrap="virtual" id="price" ><? echo $rows['price']; ?></textarea>
<br>
<input name="id_item" type="hidden" id="id_item" value="<? echo $rows['id_item']; ?>">
<input type="submit" name="Submit" value="Submit">
</form>
<?
// close connection
mysql_close();
?>
</div>
</article>
<!-- / content -->
</div>
<div class="block"></div>
</div>
<script type="text/javascript"> Cufon.now(); </script>
</body>
</html>
on submit it loads updateprices.php, it stores the price bt doesnt update the id_item or store the date.
my database table is very simple just
`id` ,
`id_item` ,
`date_start` ,
`date_end` ,
`price`
);
Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$id_item=$_POST['id_item'];
$date_start=$_POST['date_start'];
$date_end=$_POST['date_end'];
$price=$_POST['price'];
// update data in mysql database
$sql="INSERT INTO prices VALUES('id','$id_item','$date_start','$date_end','$price') ";
$result=mysql_query($sql);
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}
else {
die (mysql_error().' <br />SQL statement: '.$sql);
}
?>
ive tried it lots of ways and it still wont change the id_item