Welcome to WebmasterWorld Guest from 54.226.238.178

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


<?php
include("konek.php");
$idstud=$_SESSION['username'];

$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
//$count=mysql_num_rows($result);

?>
<form name="form1" method="post" action="insert_inscription.php">
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<thead>
<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>
</thead>
<tbody>

<?php
$i=0;
while($rows = mysql_fetch_array($result)) {
?>
<tr>
<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>
<?php
}
?>

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

</tbody>
</table>
</form>
<div class='clear'></div>
<hr/>
</body>
</html>

insert_inscription.php

<?php
require_once('auth.php');
echo $_SESSION['username'];
include("konek.php");

if(isset($_POST['Submit'])){
$sigle_cours=$_POST['sigle_cours'];
$matiere=$_POST['cname'];
$prealables=$_POST['prereq'];
$fname=$_POST['teacher'];
//$lname=$_POST['lname'];
//$completename=$_POST['fname'.'lname'];
$horaire=$_POST['jrs'];
$heure=$_POST['hre'];

$idstud=$_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");
}
else{
print ("Multiple rows inserted.\n");
}

mysql_close();
}
?>
9:24 pm on Jan 20, 2013 (gmt 0)

Administrator

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

joined:July 31, 2003
posts:12541
votes: 1


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