Hello,
I'm trying to pull 2 field of my database table categories (catdescription and subcategory) in a form field (dropdownlist) where I could select the categorydescription and in the second field it would show my different option of subcategory, which than I also like to select the one I would require. From there it should show me all the products which are in that category and subcategory. I understand that I may have to reload the page each time I make my selection.
<FORM ACTION="<? echo($PHP_SELF); ?>" METHOD=POST>
<P>categoriedescription :<BR>
<select size="1" name"catdescription">
<option value=http://www.phpbuilder.com/board/archive/index.php/"">(select a categorie)</option>
</select><BR>
<P>subcategorie :<BR>
<select size="1" name"subcategory">
<option value="">(select a subcategorie)</option>
</select><BR>
<P>Add new Product here:<BR>
<TEXTAREA NAME="productdescription" ROWS=10 COLS=40 WRAP>
</TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME="submitproduct" VALUE="SUBMIT">
</FORM>
<?
So firstly I need connect to my sql database, and secondly, I need a query like:
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", "");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
//Select the products database
if (! @mysql_select_db("JShistbau") ) {
echo ( "<P>Unable to locate the Product " .
"database at this time.</P>" );
exit();
}
$productlist = mysql_query(
"select cdescription, catdescription, subcategory " .
"from products, categories where ccategory=categories.categoryID");
while ($product = mysql_fetch_array($productlist)) {
$productdesc = $product["cdescription"];
$catdesc = $product["catdescription"];
$subcat = $product["subcategory"];
//Display the product with category
echo( "<P>$productdesc<BR>" .
"(from Categorie $catdesc $subcat)</P>" );
}
That part to query and list it in a webpage works fine, but how do I do the first part to get category and subcategory displaying into those dropdownlist in my form?
Could someone please set me up with an example?
thanx
Petra
<!-- e --><a href="mailto[email protected]">[email protected]</a><!-- e -->
I'm trying to pull 2 field of my database table categories (catdescription and subcategory) in a form field (dropdownlist) where I could select the categorydescription and in the second field it would show my different option of subcategory, which than I also like to select the one I would require. From there it should show me all the products which are in that category and subcategory. I understand that I may have to reload the page each time I make my selection.
<FORM ACTION="<? echo($PHP_SELF); ?>" METHOD=POST>
<P>categoriedescription :<BR>
<select size="1" name"catdescription">
<option value=http://www.phpbuilder.com/board/archive/index.php/"">(select a categorie)</option>
</select><BR>
<P>subcategorie :<BR>
<select size="1" name"subcategory">
<option value="">(select a subcategorie)</option>
</select><BR>
<P>Add new Product here:<BR>
<TEXTAREA NAME="productdescription" ROWS=10 COLS=40 WRAP>
</TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME="submitproduct" VALUE="SUBMIT">
</FORM>
<?
So firstly I need connect to my sql database, and secondly, I need a query like:
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", "");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
//Select the products database
if (! @mysql_select_db("JShistbau") ) {
echo ( "<P>Unable to locate the Product " .
"database at this time.</P>" );
exit();
}
$productlist = mysql_query(
"select cdescription, catdescription, subcategory " .
"from products, categories where ccategory=categories.categoryID");
while ($product = mysql_fetch_array($productlist)) {
$productdesc = $product["cdescription"];
$catdesc = $product["catdescription"];
$subcat = $product["subcategory"];
//Display the product with category
echo( "<P>$productdesc<BR>" .
"(from Categorie $catdesc $subcat)</P>" );
}
That part to query and list it in a webpage works fine, but how do I do the first part to get category and subcategory displaying into those dropdownlist in my form?
Could someone please set me up with an example?
thanx
Petra
<!-- e --><a href="mailto[email protected]">[email protected]</a><!-- e -->