Hey, got myself a tiny bit of a problem it seems. Im trying to insert a value from a section chooser drop down, but instead of inserting only the section i choose from the drop down, it inserts all the sections (if i have 1 section it selects the right section and add the data, but if i create another section it adds the data twice, one for each section).
here is the form:
PHP Code:
<form name="news" method="post" action="add_news.php">
Title:<input type="text" name="ntitle" maxlength="255"><br>
Section:<select name="section" id="section">
<?php
$result = $connector->query('SELECT sid, sname FROM nsection ORDER BY sname');
echo mysql_error();
while ($row = $connector->fetchArray($result)) {
echo '<option value"'.$row['sid'].'">'.$row['sname'].'</option>';
}
?>
</select><br>
News:<textarea name="nnews" cols="50" rows="6" id="nnews"></textarea><br>
<input type="submit" name="PostNews" value="Submit">
<input type="reset" name="reset" value="Clear"></form>
and here is the query inserting the values:
PHP Code:
$nip = $_SERVER['REMOTE_ADDR'];
$ntitle = $_POST['ntitle'];
$nnews = $_POST['nnews'];
$section = $_POST['section'];
$insertQuery = ("INSERT INTO news VALUES ( NULL , '$nip', '$ntitle', '$nnews', '$section', NOW() )");
if ($result = $connector->query($insertQuery)) {
echo ('News succesfully added');
}else{
echo mysql_error();
The Section db contains of 3 tables wich are " sid, sname, parentid ", section is the id column in the table im inserting to.
hope anyone can help me out, im loosing hair rapidly now after a few days pusling with this lol
Thanks in advance
Lazyleg
Last edited by Lazyleg; 01-15-2005 at 08:30 PM..
|