hi all ,
I was developing a blog where in admin control panel i can view the new comments.
i want to set the approval to view the comments in the blog.
problem is I used radio buttons to set permision but it did n't work properly.
I need to view the radio buttons checked according to the data base value.
i have a field name allow_cm in the data base which gives if comments is approved other wise 0.
I used ajax to make it more user friendly but when I print the comment only the last row radio button is checked.
how to solve this.
here is the code viewing comments
$qry3="select * from usercomments";
$result=mysql_query($qry3);
echo '<table border=1 align="center">'.'<thead>'.'<tr>'.'<th>'."PO_ID".'</th>';
echo '<th>'."C_ID".'</th>'.'<th>'."USER_NAME".'</th>'.'<td width=300; align="center">'."COMMENT".'</th>';
echo '<th>'."DATE".'</th>';
echo '<th>'."ALLOW".'</th>';
echo '<th>'.'DEL'.'</th>'.'</tr>';
echo '</thead>';
while($row=mysql_fetch_array($result)){
echo '<tbody>';
echo '<tr>'.'<td align="center" >'.$row['postId'].'</td>';
echo '<td align="center" >'.$row['commentId'].'</td>';
echo '<td align="center" >'.$row['name_cm'].'</td>';
echo '<td align="center" >'.$row['comment_cm'].'</td>';
echo '<td align="center" >'.$row['dateComment_cm'].'</td>';
echo '<td align="center" >';
$radioval=$row['allow_cm'];
if($radioval==1){
echo "Yes".'<input type="radio" name="yes" value="1" checked="checked" onclick="callChange(this.value)"/>';
echo "No". '<input type="radio" name="no" value="0" onclick="callChange(this.value)"/>';
}else{
echo "Yes".'<input type="radio" name="yes" value="1" onclick="callChange(this.value)"/>';
echo "No". '<input type="radio" name="no" value="0" checked="checked" onclick="callChange(this.value)"/>';
}
echo '</td>';
$cmId=$row['commentId'];
$poId=$row['postId'];
echo "<td align='center'><input type='button' value='Del' id='del'.'$cmId'.'$poId' onclick='delcomment(".$cmId.",".$poId.")'>"."</td>";
echo '</tr>';
this is the javascript I used.
function callChange(str)
{
if (str=="")
{
document.getElementById("contentbox").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("contentbox").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","delete.php?q3="+str,true);
xmlhttp.send();
}
thx in advance,menuka