php arrays and mysql
can anyone help me with this?
i've got 3 values that will be dynamic rooms, rates and dates. i'm posting them onto another page wherein it will be inserted into a database. right now, i'm using room[], dates[] and rates[] and retreiving these values using the for..each loop my problem is how do i insert the values to the corrosponding rooms and dates since i'm just able to insert only the last values generated. is there a way out? |
not totally sure what you're asking... can you provide the sample code you have got so far to explain why it's not sufficient?
|
here's some code
file 1 <input type=text name=room> <input type=text name=dateval[]> <input type=text name=values[]> file 2 $roomid = $_POST['room']; $dateval =$_POST['dateval']; $rvalues =$_POST['values']; foreach($dateval as $dvals) { $sql = "insert into tbl (id, datevalues) values ($roomid,'$dvals')"; $res = mysql_query($sql); } foreach($dateval as $dvals) { foreach($rvalues as $s) { $sql1 = "UPDATE tbl SET val= '$s' WHERE id=$roomid and dt='$dvals'"; $res1 = mysql_query($sql1); } } |
All times are GMT -5. The time now is 04:07 PM. |