Hey,
I’m new to php and having a little trouble making a bit of code work.
What i’m trying to do it show results from various mySQL table. However i only want it to get data from a certain table depending on what is in a cell.
What i have so far doesn’t not work but will post anyway encase it helps you to understand what im trying to do.
I know why this isnt working its just i dont know how to to it. The problem here is that i want it to check each row. The mySQL query works and gives me everything i want when run in php myadmin but when trying to show on php it doesnt work.
$result = mysql_query(
"SELECT *
FROM `activity`
ORDER BY activity.activityID DESC"
);
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
?>
<table class='rcolumn' width='703px' border='1' cellpadding='0' cellspacing='0'>
<?
while($rows=mysql_fetch_array($result)){
if ($rows['description'] == 'Client Added')
{
$find = mysql_query(
"SELECT *
FROM `activity`
LEFT JOIN `clientdetails` ON activity.clientdetails_ClientID = clientdetails.clientID
WHERE description = 'Client Added'
ORDER BY activity.activityID DESC ");
$urlend = $rows['clientdetails_ClientID'];
$url = 'clientdetails.php?client='.$urlend;
}
elseif ($rows['description'] == 'New Enquiry')
{
$find = mysql_query(
"SELECT *
FROM `activity`
LEFT JOIN `clientdetails` ON activity.clientdetails_ClientID = clientdetails.clientID
LEFT JOIN `enquiry` ON activity.enquiry_enquiryID = enquiry.enquiryID
WHERE description = 'Client Added'
ORDER BY activity.activityID DESC");
$urlend = $rows['enquiry_enquiryID'];
$url = 'enquirydetails.php?enquiry='.$urlend;
}
elseif ($rows['description'] == 'New Quote')
{
$find = mysql_query(
"SELECT *
FROM `activity`
LEFT JOIN `clientdetails ON activity.clientdetails_ClientID = clientdetails.clientID
LEFT JOIN `quotesummery` ON clientdetails.clientID = quotesummery.ClientDetails_ClientID
WHERE activity.enquiry_enquiryID = enquiry.enquiryID
ORDER BY activity.activityID DESC");
}
else
{
}
// sending query
?>
<?
// printing table
?>
<tr class="row" onclick="DoNav('<? echo $url;?>');">
<td width="100px"><? echo $rows['QuoteID']; echo $rows['Initial']; echo $rows['StaffInitial'] ?></td>
<td width="150px"><? echo $rows['description'];
?></td>
<td width="150px"><? echo $rows['FirstName']?> <? echo $rows['LastName']; ?></td>
<td width="150px"><? echo $rows['Car']; ?></td>
<td width="100px"><? echo $rows['Country']; ?></td>
</tr>
<?
}
mysql_free_result($result);
?>
</table>