Page 1 of 1

Forms help

Posted: Sat Dec 27, 2003 12:20 pm
by therat
I need to be able to show a list of category titles in a database with a link to another form that show all the detail of the category, where I can edit the info.
I have the following that lists out the categories but, how do I get individual details to show. This file is called as an include so I assume the details form should be in the same file.

Code: Select all

<?php
$skinz = my_conn();

$query_list_cats = "SELECT * FROM skinz_categories ORDER BY cat_name ASC";
$list_cats = mysql_query($query_list_cats, $skinz) or die(mysql_error());
$row_list_cats = mysql_fetch_assoc($list_cats);
$totalRows_list_cats = mysql_num_rows($list_cats);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="6"><img src="images/tile_back_l.gif" alt="" border="0"></td>
      <td align="left" class="maintitle"><img src="images/nav_m.gif" alt="" width="17" height="8" border="0">Edit Categories</td>
      <td width="6"><img src="images/tile_back_r.gif" alt="" border="0"></td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableborder">
    <tr>
      <td width="33%" align="center" class="darkrow1">Title</td>
      <td width="33%" align="center" class="darkrow1">Edit</td>
      <td width="33%" align="center" class="darkrow1">Remove</td>
    </tr>
    <?php do &#123; ?>
    <tr>
      <td><?php echo $row_list_cats&#1111;'cat_name']; ?></td>
      <td width="33%" align="center"><a href="<?php echo $row_list_cats&#1111;'cat_id']; ?>">Edit</a></td>
      <td width="33%" align="center"><a href="<?php echo $row_list_cats&#1111;'cat_id']; ?>">Remove</a></td>
    </tr>
    <?php &#125; while ($row_list_cats = mysql_fetch_assoc($list_cats)); ?>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="6" height="9"><img alt="" src="images/bottom_left.gif"></td>
      <td width="100%" background="images/bottom.gif"><img alt="" src="images/bottom.gif"></td>
      <td width="6" height="9"><img alt="" src="images/bottom_right.gif"></td>
    </tr>
  </table>
<?php
mysql_free_result($list_cats);
?>

hmm

Posted: Sun Dec 28, 2003 3:08 am
by mwong
You could do it with one or two files.

Let's say you have two files:

The first one would be called cat_title.php (this is what I assume the code you have posted)

Now when you click on one of the categories you want to edit....the "edit" link will point toward the second page (cat_details.php) the link will look something like this:

cat_details.php?cat_name="$cat_name" (the $cat_nam should be the name of the category.

The second page will pull that cat_name information and query your database and fill the form fields so you can edit the information.

If you have one page:

I suppose you could have an if() statement to see if the cat_name variable in the url isset(). If it is then it will echo the form with the details of the category filled in.

*shrug* I'm kinda a newbie too...so I'm not sure how to explain....lemme know if you need a better explaination

Posted: Sun Dec 28, 2003 5:58 am
by therat
Thanks, ill give that a go.