Ok, I have been trying to get the hang of multiple tables for a project. So far I have used an admin script with no problems when I used only one table.
I am slowly adding multiple table support to this script. I figure conquer one problem at a time... however each time I try to fix a problem, the more that pop up.
The script so far starts with a waning of Invalid argument supplied for foreach(). This most likely is my partial support for multiple tables, but I don't know where. I can update, but not insert and the update only works on the Business table so far.
Here is the line that seems to be the problem:
// update BUSINESS table
$SQL="UPDATE Business SET b_name='$b_name', b_address='$b_address', b_city='$b_city', b_state='$b_state', b_image='$b_image' WHERE bid=$bid";
$result=mysql_query($SQL,$dB);
// update BUSINESS_CATEGORY table
foreach($_POST['parent'] as $val)
{
$SQL2="UPDATE Business_Category SET bid='$bid' WHERE cid='$val'";
$result2=mysql_query($SQL2,$dB);
}
It could be a problem else where in the script, so I made a copy of everything for testing (please be nice):
http://atomiccoffeemedia.com/southms/admin/
I have added a "view source" link so you can see what is going on (and not post the whole code here🙂. The Category link works great, because it uses only one table. The Business Category link is the one that uses multiple tables, so that is what is going bad.
I know that there is probably a million things wrong here, but any help would be sooo much appreciated. I have been working on this for days, and fresh eyes are needed!
Here are my tables:
Business;
+-----------------+-----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-----------------------+------+-----+---------+----------------+
| bid | mediumint(8) unsigned | | PRI | NULL | auto_increment |
| b_name | varchar(50) | | | | |
| b_address | varchar(100) | | | | |
| b_city | varchar(30) | | | | |
| b_state | char(3) | | | | |
| b_zip | int(12) | | | 0 | |
| b_county | varchar(30) | | | | |
| b_phone | int(11) | | | 0 | |
| b_contact_first | varchar(20) | | | | |
| b_contact_last | varchar(30) | | | | |
| b_website | varchar(100) | | | | |
| b_email | varchar(100) | | | | |
| b_image | varchar(100) | | | | |
| b_paid | char(3) | | | | |
| b_comment | text | | | | |
+-----------------+-----------------------+------+-----+---------+----------------+
Business_Category;
+-------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
| bid | int(10) unsigned | | PRI | 0 | |
| cid | int(10) unsigned | | PRI | 0 | |
+-------+------------------+------+-----+---------+-------+
Category;
+--------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+----------------+
| cid | int(11) | | PRI | NULL | auto_increment |
| name | varchar(100) | | | | |
| parent | varchar(100) | | | | |
+--------+--------------+------+-----+---------+----------------+