I am developing an e-commerce system and I want to be able to create catagories and subcatagories for items. I have the basics down however I may be making things too complicated. First I select a parent catagory and the page sucessfully brings me to the subcatagory screen, however anything past that, the catagory id variable is not being passed back to the application. Here is the code, hopefully someone can understand what I'm trying to do and figure out what's wrong, my brain is about to explode. Thanks again!
Expand|Select|Wrap|Line Numbers
- $catid = $_POST['catid'];
- $catdesc = $_POST['catdesc'];
- echo "<h1>Catagory ID: " . $catid . "</h1>";
- if ($catid == '')
- {
- $buildsql = "SELECT * FROM catagories WHERE parent=0";
- $result = mysql_query($buildsql);
- $numrows = mysql_num_rows($result);
- if($numrows <= 0)
- {
- echo "<h1>There are no catagories!</h1>";
- }
- echo "<br><br><form action='catagory.php' method='post'><table align='center' border='1'><tr><td bgcolor='#C0C0C0' align='center'><b>Select Parent Catagory</b></td></tr>";
- echo "<tr><td align='center'><select size='10' name='catid'>";
- while($rowset = mysql_fetch_array($result))
- {
- echo "<option id=" . $rowset[catid] . " value=" . $rowset[catid] . ">" . $rowset[description] . "</option>";
- }
- echo "</select><br><p align='right'><input type='submit' value='Next ->' /></p></td></tr></form></table>";
- }
- else
- {
- //find sub-catagories
- $buildsql = "SELECT * FROM catagories WHERE catid=" . $catid;
- $result = mysql_query($buildsql);
- $rowset = mysql_fetch_array($result);
- $catdesc = $catdesc + $rowset[description] . " ->";
- $buildsql = "SELECT * FROM catagories WHERE parent=" . $catid;
- $result = mysql_query($buildsql);
- $numrows = mysql_num_rows($result);
- If($numrows <= 0)
- {
- echo "<h1>code your submit catagory here!</h1>";
- }
- else
- {
- echo "<br><br><form action='catagory.php' method='post'><table align='center' border='1'><tr><td bgcolor='#C0C0C0' align='center'><b>Select Sub-Catagory</b></td></tr>";
- echo "<tr><td align='center'><select size='10' name='catid'>";
- while($rowset = mysql_fetch_array($result))
- {
- echo "<option id=" . $rowset[catid] . " value=" . $rowset[catid] . ">" . $rowset[description] . "</option>";
- }
- echo "</select><br><p align='right'><input type='submit' value='Next ->' /></p></td></tr></form></table>";
- }
- }
- mysql_close($con);