Hi there,
I am trying to make checkbox check based on query for editing of pages !
All seem to work fine, inserting, updating, deleting.
Only 1 thing that makes my life miserable at the moment is this checkbox, somehow doesnt want to be checked.
Can u help me so that this thing get checked???
My code is this :
<?
if ($do == "update")
{
$sel = mysql_query("SELECT * from html_pages where categories_id = '" . $id . "'");
if (mysql_num_rows($sel) == 0 )
{
$ad = mysql_query("INSERT INTO html_pages (html_text, page_name,categories_id) values ('" . $html_text . "', '" . $page_name . "','" . $catid . "')");
}
else
{
$upd = mysql_query("UPDATE html_pages SET html_text = '" . $html_text . "', page_name = '" . $page_name . "' WHERE categories_id= '" . $id . "'");
}
}
if ($do == "ed")
{
$sel = mysql_query("SELECT * from html_pages where categories_id = '" . $id . "'");
$row = mysql_fetch_array($sel);
}
if ($do == "del")
{
$del = mysql_query("DELETE FROM html_pages where categories_id = '" . $id . "'");
}
?>
<?php include("lang.php"); ?>
<table width="100%" border="0">
<tr>
<td width="100%" height="53" valign="top" class="titletext"><p><strong> <?php echo $lang[menustranica]; ?></strong></p>
<? if ($action <> "ed")
{
$id = -1;
}
?>
<?php
$sql = "select * from categories order by categories_id";
$result = mysql_query($sql ,$db);
$newrowcount = 0;
printf("<table><tr>");
if ($myrow = mysql_fetch_array($result)) {
do {
if ($newrowcount == 4) {
$newrowcount = 0;
printf("</tr>");
printf("<tr>");
}
/// printf("<td><input type=radio name=catid value=%s> %s</td> ", $myrow["categories_id"], $myrow["categories_name"]);
// here is the one that needs to be cheked based on query for editing, updating
echo "<td><input type='radio' name='catid' value= <td>",$myrow["categories_id"], $myrow["categories_name"];
?>
<?
$newrowcount++;
} while ($myrow = mysql_fetch_array($result));
}
for ($c = $newrowcount; $c < 4; $c++) {
printf("<td></td>");
}
printf("</tr></table>");
?>
</td>
</tr>
<tr class="texttabel">
<td> <div align="right">
<? if ($do == "ed") { ?>
<input name="image" type="image" title=" Update " src="img/button_update.gif" alt="Update" width="65" height="22" border="0">
<? } ?>
<? if ($do <> "ed") { ?>
<input name="image2" type="image" title=" Insert " src="img/button_insert.gif" alt="Insert" width="65" height="22" border="0">
<? } ?>
</div></td>
<td><a href="index.php?action=aboutstranice&id=<? echo $id ?>"><img src="img/button_cancel.gif" width="65" height="22" border="0"></a></td>
</tr>
</table>
</form>
<table width="100%" border="0">
<tr class="texttabel">
<td width="18%" bgcolor="#CCCCCC"><strong><?php echo $lang[stranicalink]; ?></strong></td>
<td width="14%" bgcolor="#CCCCCC"> <div align="center"><strong><?php echo $lang[edit]; ?></strong></div></td>
<td width="13%" bgcolor="#CCCCCC"> <div align="center"><strong><?php echo $lang[delete]; ?></strong></div></td>
</tr>
<?
$sel_tot = mysql_query("SELECT * from html_pages");
for ($k = mysql_num_rows($sel_tot) - 1; $k >= 0; $k--)
{
mysql_data_seek($sel_tot, $k);
$row_tot = mysql_fetch_array($sel_tot);
?>
<tr class="texttabel">
<td><? echo $row_tot[2]?></td>
<td><div align="center"><strong><a href="index.php?action=aboutstranice&do=ed&id=<? echo $row_tot[0]?>"><font size="-2"><?php echo $lang[edit]; ?></font></a></strong></div></td>
<td><div align="center"><strong><a href="index.php?action=aboutstranice&do=del&id=<? echo $row_tot[0]?>"><font size="-2"><?php echo $lang[delete]; ?></font></a></strong></div></td>
</tr>
<?
}
?>
</table> </td>
</tr>
</table>
Thank u all for looking at my begginer code.
Regards,
Rutin