Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

multiple insert with checkbox

Hello guys, please help me i cant insert anything in the inscription table

7:47 pm on Nov 1, 2012 (gmt 0)

New User

joined:Nov 1, 2012
posts: 1
votes: 0


$sql="SELECT sigle_cours,cname,prereq,CONCAT_WS(' ',fname, lname ),jrs,hre
FROM horaire
LEFT JOIN teacher ON horaire.tID=teacher.tID
LEFT JOIN courses ON horaire.cID=courses.cID
INNER JOIN students
ON students.progID=courses.progID
where st_userName='$idstud' and NO_semester=1";
$result = mysql_query($sql);
// Count table rows

<form name="form1" method="post" action="insert_inscription.php">
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr> <div align="center"><th>Session I</th></div></tr>

<tr> <th></th><th>Sigle_cours</th> <th>Matiere</th> <th>Prealables</th> <th>Professeurs</th> <th>Jours</th> <th>Horaire</th> </tr>

while($rows = mysql_fetch_array($result)) {
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $i++;?>" /></td>

<td align="center">
<input name="sigle_cours[]" type="text" id="sigle_cours" value="<?php echo $rows['sigle_cours'];?>"></td>

<td align="center"><input name="cname[]" type="text" id="cname" value="<?php echo $rows['cname'];?>"></td>

<td align="center"><input name="prereq[]" type="text" id="prereq" value="<?php echo $rows['prereq'];?>"></td>

<td align="center"><input name="teacher[]" type="text" id="teacher" value="<?php echo $rows["CONCAT_WS(' ',fname, lname )"];?>"></td>

<td align="center"><input name="jrs[]" type="text" id="jrs" value="<?php echo $rows['jrs'];?>"></td>

<td align="center"><input name="hre[]" type="text" id="hre" value="<?php echo $rows['hre'];?>"></td>

?> -->
<tr><td><input name="Submit" type="submit" id="Submit" value="Submit"></td></tr>
<!--<td><input type="reset" name="cleared" value="Clear"/></td> -->

<div class='clear'></div>


echo $_SESSION['username'];


foreach($_POST['checkbox'] as $i) {
$strSQL ="insert into inscription values(NULL,(SELECT hID FROM horaire
LEFT JOIN teacher ON horaire.tID=teacher.tID
LEFT JOIN courses ON horaire.cID=courses.cID
where sigle_cours='$sigle_cours'][$i]'
and cname='$matiere[$i]' and prereq='$prealables[$i]'
and CONCAT_WS(' ',fname,lname)='$fname[$i]'
and jrs='$horaire[$i]' and hre='$heure[$i]'),(SELECT stID FROM students WHERE st_userName='$idstud'),2,'NOW()'
$objQuery = mysql_query($strSQL);
if (!$objQuery) {
print("SQL statement failed with error:\n");
//print(" ".mysql_get_last_message()."\n");
print ("Multiple rows inserted.\n");

9:24 pm on Jan 20, 2013 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 2

Hello hudexavier and welcome to WebmasterWorld.

What error(s) are you receiving, if any?

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members