|
Posted by sicapitan on 10/03/64 11:43
Hi There, not sure if this can be done with SQL or if there is an SQL
crossover
I have two tables:
Table "record":
id, record_id, data1, data2
Table "subrecord":
id, record_id, name, value
In the subrecord the name contains the header title, and the value the
value. I need to:
1. Search the database
(`name` = 'firstname' AND `value` LIKE %'somevalue%') AND
(`name` = 'emailaddress') AND `value` LIKE '%somevalue%')
2. Present the data like this :
foreach distinct `name` echo `name`
then
foreach `value` echo `value`
What I've got so far is the query linking the record to the subrecord,
so I can get all the data into an array with the names:
do {
$thelist['record_id'][] = $row_forms['record_id'];
if ( $row_forms['name'] == "firstname" ) $thelist['firstname'][] =
$row_forms['value'];
if ( $row_forms['name'] == "emailaddress" ) $thelist['emailaddress'][]
= $row_forms['value'];
} while ($row_forms = mysql_fetch_assoc($forms));
Can i do this on a SQL level to avoid getting all the data into an
array record_id, then render results which match those id's. Sounds
overly complicated and confusing.
Any help appreciated. Thanks!
Ryan
[Back to original message]
|