There is field name “model” for all products in products table.
there is one category “ACCESSORIES” in which “model” field has values like “e71,e72,e73,e74…” all together in one field, because some accessories are compatible with many phones.
when e71 phone is displayed on the page, then i want to display accessories whose “model” field has values e71.
here is what i have tried
/* query to select all models from accessory table */
$qry_model="select * from product_table where status='Y'and category_id=4";
$qry_model_result=mysql_query($qry_model);
while($qry_model_row=mysql_fetch_array($qry_model_result))
{
$desc_model_all = $qry_model_row['model'];
$desc_model_all = explode(',', $desc_model_all);
}
/* query to display accessories */
$qryc="select * from product_table where model LIKE '$desc_model_all[0]' and status='Y' and category_id=4";
i m stuck with the limitation of my display query.
because i will have to write
'$desc_model_all[0]' '$desc_model_all[1]' and so on....
i m stuck with the limitation of my display query.
You are plumbing the depths of what you can with arrays kept in a table, so perhaps you can now better understand [google]the purpose of normalizing data in a database[/google].
Field works with column names? I was trying to do it with a single query rather than pulling all results and then filtering in a separate one. Yes, it’s very clumsy, which IS why the data should be normalized.