Wednesday, 2 October 2013

It`s a quick fix, but i`ve tried it all, nothing works

It`s a quick fix, but i`ve tried it all, nothing works

So i made this code:
$a = 0;
$rezultat = "SELECT id, materie
FROM materii
ORDER BY id";
$rezultat1 = mysql_query($rezultat);
while($plm = mysql_fetch_array($rezultat1))
{
if($a++ %5 == 0) echo "<tr>";
?>
<td align="center"><input type="checkbox" name="checkbox2[]" value="<?php
echo $plm['id']; ?>" /></td>
<td style="text-align:left"><?php echo $plm["materie"];
?>&nbsp;</td>
<?php
if($a %5 == 0) echo "</tr>";
}
?>
</table>
</div>
<br/>
<input type="reset" value="Sterge" /> <input type="submit"
value="Salveaza" name="savebtn" />
</form>
<?php
if(isset($_POST['savebtn']))
{
foreach($_POST["checkbox2"] as $loc_id)
{
$query = "INSERT INTO materii_pe_clase(id_scoala,id_clasa,id_materie)
VALUES('$scoalalui','$clasalui','$loc_id')"; //aici cauta ! :))
$result5 = mysql_query($query)
or die('sa iti bagi pula in mata');
}//sfarsit foreact
}//sfarsit if isset
Why does the last query not work? p.s. its a school project, so mysql is
ok, no need for mysqli. p.p.s I defindet the $scoalalui and $clasalui
somwhere a little up the page. but they are not the problem, i tried
replacing them with values. the query simply does not work. thanks!
thank you all!

No comments:

Post a Comment