View Single Post
  #2 (permalink)  
Old 10-04-2008, 10:30 AM
afroman afroman is offline
Novice Webmaster
 
Join Date: Oct 2005
Location: KLC
Posts: 89
Rep Power: 37
afroman is on a distinguished road
Send a message via ICQ to afroman Send a message via Yahoo to afroman
Quote:
Originally Posted by emnieysh View Post
for example :

i have 2 student

Hasanah TT074921 5(marks)
Syakirah TT074318 4(marks)

*marks was a textbox fill..went i insert mark n submit it,
only Syakirah TT074318 4 was insert into db..so how should i do to insert HASANAH n SYAKIRAH record in db..
a few methods can be used. but easiest is to use array.
Code:
<input type="text" name="student[1]"...
<input type="text" name="mark[1]"...

<input type="text" name="student[2]"...
<input type="text" name="mark[2]"...
in the action script..

Code:
$student = $_POST['student'];

foreach ($_POST['mark'] AS $i => $v) {

    mysql_query("INSERT INTO table VALUES ('%s', %d)", $student[$i],  $v);
}
btw, fine=elok/baik, find=jumpa/cari...
__________________
klaatu barada nikto
Reply With Quote