more radio problems * sighs * been at this for one week now
Posted
by jeansymolanza
on Stack Overflow
See other posts from Stack Overflow
or by jeansymolanza
Published on 2010-06-09T04:22:19Z
Indexed on
2010/06/09
4:32 UTC
Read the original article
Hit count: 221
hi guys
really i don't know what im doing wrong... i am trying to process multiple radios with mysql. the first step has involved me echoing the results on the process page. each time i select any radio option it simply displays the first row result. this is that i see after trying to submit the form:
Notifications
Thank you. The notifications have been updated successfully.
statusid: 14 notc2: 1
Return
this is the code for the form:
<div style="padding: 15px;">
<span class="loginfail" style="font-size:24px; font-weight: bold">Notifications</span><p>
<?php include("progress_insertcomment.php"); ?>
<?php
// Make a MySQL Connection
mysql_select_db("speedycm_data") or die(mysql_error());
$query_comment = "select * from tbl_alert order by id desc limit 1";
$comment = mysql_query($query_comment, $speedycms) or die(mysql_error());
$row_comment = mysql_fetch_assoc($comment);
$totalRows_comment = mysql_num_rows($comment);
?>
<!--- add notification --->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<span id="sprytextarea1">
<textarea id='comment' name="comment" style="height: 75px; width:330px;"><?php echo $row_comment['comment']; ?></textarea>
</span>
<p>
<button type="submit">Add</button>
<input type="hidden" name="notc" value="1"/>
</form>
<!--- notification history --->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="2" cellpadding="2">
<?php
if ( $row_comment == 0 ) {
echo "<span style='font-size: 11px;'>No current alerts.</span>";
} else {
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM tbl_alert ORDER BY id DESC")
or die(mysql_error());
while($rows=mysql_fetch_array($result)){ ?>
<tr>
<td>
<?php
echo "<div class='bubble'><div class='pimped'>
<blockquote>" . $rows['comment'] . "
</blockquote></div>
<cite><strong>" . $rows['user'] . "</strong> @ " . $rows['date'] . "</cite>
<span style='font-size: 10px;'>
<p>
<a href='editalert.php?id=". $rows['id'] ."' class='form' >Edit</a> • <a href='deletealert.php?id=". $rows['id'] ."' class='form'>Delete</a>
</span>
</div>
";
?>
</td>
<td valign="top" align="center"><div style="padding-left: 30px;"><span style="font-size: 10px;">Completed?</span>
<p class="field switch">
<!--- determine status of notification --->
<?php
$status = $rows['status'];
$id = $rows['id'];
?>
<input type="radio" name="selstatus[<?php echo $id; ?>]" value="no" <?php if($status == 'yes') {echo 'checked';} else {echo '';} ?>/>
<input type="radio" name="selstatus[<?php echo $id; ?>]" value="yes" <?php if($status == 'yes') {echo 'checked';} else {echo '';} ?>/>
<input type="hidden" name="statusid" value="<?php echo $id; ?>"/>
<label for="radio1" class="cb-enable <?php if($status == 'yes') {echo 'selected';} else {echo '';} ?>"><span>Yes</span></label>
<label for="radio2" class="cb-disable <?php if($status == 'no') {echo 'selected';} else {echo '';} ?>"><span>No</span></label>
</p>
</div></td>
</tr>
<tr>
<td></td>
<?php
}
}
?>
<td align="center"><div style="padding-left: 30px;">
<button type="submit">Update</button>
<input type="hidden" name="notc2" value="1"/>
</div></td>
</tr>
</table>
</form>
</div>
this is the code for the processing page:
<?php
// 6) update notifications
if (array_key_exists('notc2',$_POST)) {
$update = $_POST['selstatus'];
echo "<p style='font-size: 12px;'>Thank you. The notifications have been updated successfully.<p>";
foreach($_POST as $key => $value){
echo $key . ': ' . $value . '<br>';
}
echo "<p><span style='font-size: 12px;'>
<a onClick=\"history.go(-1)\" class='form'>Return</a></p>
<p></span>
";
exit;
};
?>
how do i resolve this problem? please any help would be appreciated. i would like to display the id and value of the selected checkbox on the processing page before inserting it into the table. thanking you in advance.
GOD BLESS
© Stack Overflow or respective owner