Hi
I am having trouble simplifying my mysql query.
I have 3 tables I need to verify data in before I add new data to it.
The code is as follows:
(this takes place after all validation of form data has been completed.)
if (empty($errors)) { //If all is ok. Data caused no errors
//Test for unique records. Product name and url and prod type and price
$query1 = "SELECT id FROM products WHERE prod_name='$prod_name' AND url=$url";
$result1 = mysql_query($query1);
$query2 = "SELECT id FROM sizes WHERE size=$size";
$result2 = mysql_query($query2);
$query3 = "SELECT id FROM prod_type WHERE prod_type=$type_of";
$result3 = mysql_query($query3);
$row_result1 = mysql_num_rows($result1);
$row_result2 = mysql_num_rows($result2);
$row_result3 = mysql_num_rows($result3);
//This means key entries are identical. Prevent user from entering duplicate data
if ( ($row_result1 && $row_result2 && $row_result3) == 1) {
$errors[] = 'You may have entered this item before, please check your data again.';
} else {
//Run the query
The tables I want to pull from are:
products, prod_type and sizes
Is there a way i can use joins to minimize my queries?
I appreciate all your help.
Thank you kindly in advance.
-r