displaying more than 2 table in one insert form

Hi guys,

i’m abit confuse of how to display multiple table information in an insert form

below is my description.

i have a product table which i want to to insert to.

So, i have a category and sub category to dropdown menu to choose the data from.

So, my initial idea are during the insert to product table, how do i call the category and sub category information to display on the product insert form?

Do you not use query builder?

I’m guessing you will have some kind of relationship between the 2 tables such as parent_id or the such?

If so, use INNER JOIN

[php]SELECT categories.id, categories.title, categories.url subcategories.id, subcategories.title, subcategories.url
FROM categories INNER JOIN
subcategories ON categories.id = subcategories.parent_cat
WHERE (categories.id= :id) AND (subcategories.id= :id)
ORDER BY categories.id DESC")[/php]

The above will work with PDO. If you can’t be bothered to learn PDO, ask someone else, if you’d like to learn how to securely run your queries, let us know and we’ll help. I’m not supporting mysql_query any more as it’s now deprecated and will be removed from future PHP versions.

Sponsor our Newsletter | Privacy Policy | Terms of Service