All:
I have one big mess that I don't know how to describe well but here it goes. I am having trouble displaying array data.
I have a record with the column name "eventid" filled with comma separated values. I need every array value matched with another table that has its name.
*NOTE: An id or record in the contact table can have multiple events.
Example:
tblContact
id = 1, eventid = 1, 2, 3
match with
tblEvents
id = 1, eventName = Spring
id = 2, eventName = Summer
id = 3, eventName = Fall
which means
tblContact
id = 1, eventid = 1(spring), 2(summer), 3(fall)
List page code:
Could I possibly create another while loop inside of the while loop to display the matching event name?
Thank you for any help.
I have one big mess that I don't know how to describe well but here it goes. I am having trouble displaying array data.
I have a record with the column name "eventid" filled with comma separated values. I need every array value matched with another table that has its name.
*NOTE: An id or record in the contact table can have multiple events.
Example:
tblContact
id = 1, eventid = 1, 2, 3
match with
tblEvents
id = 1, eventName = Spring
id = 2, eventName = Summer
id = 3, eventName = Fall
which means
tblContact
id = 1, eventid = 1(spring), 2(summer), 3(fall)
List page code:
Code:
$sql = @mysql_query('SELECT contact.id, company.company_companyName, contact.contact_firstName, contact.contact_lastName, contact.contact_title, contact.contact_response, events.eventName, contact.eventid
FROM `contact`
left join `company` ON contact.companyid = company.id
left join `events` ON contact.eventid = events.id
ORDER BY contact.id DESC');
if(!sql){
exit('<p>Error in Sql statement!<br />'.
'Error: ' .mysql_error() . '</p>');
}
while ($sql1 = mysql_fetch_array($sql)) {
$id = $sql1['id'];
$companyName = htmlspecialchars($sql1['company_companyName']);
$firstName = htmlspecialchars($sql1['contact_firstName']);
$lastName = htmlspecialchars($sql1['contact_lastName']);
$title = htmlspecialchars($sql1['contact_title']);
$eventid = htmlspecialchars($sql1['eventid']);
$response = htmlspecialchars($sql1['contact_response']);
echo "<tr>".
"<td>$id</td>".
"<td>$companyName</td>".
"<td>$firstName</td>".
"<td>$lastName</td>".
"<td>$title</td>".
"<td>$eventid</td>".
Could I possibly create another while loop inside of the while loop to display the matching event name?
Thank you for any help.