Hello
I have made this code for querying a database and returning results in a table.
My problem is - if there are no results I want it to say something along the lines of
' sorry search again'
How do I put that into my code though?
This is my code
if ($GET['date_search'] != "All")
if ($GET['type_search'] != "All")
{
$result = odbc_exec($connect, "SELECT doc_date_yr, doc_url, doc_title
FROM documents
INNER JOIN doc_types
ON documents.doc_id=doc_types.doc_id
WHERE doc_types.type_id=" . $GET['type_search'] . "
AND doc_date_yr = '" . $GET['date_search'] . "'
ORDER BY doc_date_yr DESC
");
?>
<table class="results">
<tr>
<th class="year">Year</th><th class="title">Title</th>
</tr>
</table>
<?
while ($row = odbc_fetch_array($result))
//return the titles acting as hyperlinks to the documents themselves
{ echo "
<table class=results>
<tr>
<td class=year>" .$row['doc_date_yr'] . "</td>
<td class=title><a href=" . $row['doc_url'] . " target=blank>" . $row['doc_title'] . "</a></td>
</tr>
</table>";
}
}