|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Add items to new category
Currently I am using a script to insert item in an 'items' table and a seperate script to add categories to the 'categories' table. The items table has a field called cat_id and references an id field in the categories table. I need to use a drop down box so that cat_title is displayed from 'categories' but a cat_id is inserted. Here is the code I am using now. Unfortunately if I use a new category with no items the new cat_id is assigned as zero.
<? $dbcnx = @mysql_connect( "host", "test", "test"); mysql_select_db("testdb"); $query = "SELECT distinct cat_id, cat_title from store_items right join store_categories on store_items.cat_id = store_categories.id"; $result = mysql_query($query); print "<SELECT name=cat_id>"; while ($line = mysql_fetch_array($result)) { foreach ($line as $cat_id) { print "<OPTION value='$cat_id'"; } print ">$cat_id</OPTION>"; } print "</SELECT>"; ?> I am very new to this - any help is greatly appreciated. |
|
#2
|
|||
|
|||
|
RE: Add items to new category
|
|
#3
|
|||
|
|||
|
RE: Add items to new category
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Add items to new category |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|