I am writing a catologe application and i have a problem when it comes to the edit product part. I have a table with the catogories and a table with manufacturers. Each table has a id column and a name column. The id column is set up in the MySQL to auto_increment, which works fine normally, but i am writing this script:

function edit_cat_radio($item_cat_id)
{
   connect();
   $sql = "SELECT * FROM cat DISTINGT ORDER BY cat_id";
   $result = mysql_query($sql);
   $k = 1;
   while ($row = mysql_fetch_assoc($result))
       {
       extract($row);
echo '<label for="',$cat_name,'">',$cat_name,'<input type="radio" name="fcat" value="',$cat_id,'" id="',$cat_id,'"';
       if($k == $item_cat_id)
       {
           echo 'checked';
       }
       echo ' />';
       $k++;
   }
return; }


This should (in theory) automatically check the radio button of the existing catogory. It would work fine; but what seems to mess it up is the auto_increment.

If i delete a catogory/manufacturer from the id's remain the same. and end up like this:
cat_id     cat_name
1     Bridlework
2     Clippers
3     Clothing
4     Dressage Tests
5     DVD/Video/Books
9     Footwear

but if the cat_id is 9 the /while /statement doesnt repeat 9 times so the counter never reaches 9.

I don't know if you got all that, its hard to explain.

I would appreciate any help on how to sort this out.

Thanks

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to