homepage Welcome to WebmasterWorld Guest from 54.166.228.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
multiple insert with checkbox
Hello guys, please help me i cant insert anything in the inscription table
hudexavier




msg:4514778
 7:47 pm on Nov 1, 2012 (gmt 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();
}
?>

 

coopster




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

Hello hudexavier and welcome to WebmasterWorld.

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved