Hi,
please examin this code
if(isset($_POST['submit'])){
for($i = 1; $i <= $this->pnum; $i++){
if($_POST["text$i"] == "")
{
throw new Exception('You have to fill all options');
}
}
for($i = 1; $i <= $this->pnum; $i++){
$option = $_POST["text$i"];
$pollq2 = $SiteDatabase->dbqueries("INSERT INTO
" . BhlPoll::BHL_DB_PREFIX . "" . BhlPoll::BHL_POLL_V . " (`pid`, `options`, `optid`)
VALUES (
'".$_GET['pid']."',
'".mysql_real_escape_string($option)."',
'".mysql_real_escape_string($this->pnum)."')") or die(mysql_error());
}
}else{
?>
<form action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>?action=rpoll&pnum=<?PHP echo $this->pnum; ?>' method='post'>
<fieldset>
<legend>Poll Form</legend>
<p>Fields marked * are compulsory.</p>
<dl>
<dt><label for='username'>Poll Question: *</label></dt>
<?PHP
for($i = 1; $i <= $this->pnum; $i++){
echo "<dd>option".$i." : <input type='text' name='text$i' id='name' value='' /></dd>";
echo "text$i";
}
?>
<dd><input type="submit" name="submit" value="Add a poll" /><dd>
</dl>
</fieldset>
</form>
<?PHP
}
this code works fine
The problem in [INSERT INTO]. I need to insert [for looping $i] into [option column]
and the other columns remain without any changes. I try many time but other columns repeat when (for looping $i) repeats.