I finally got a good working search script for our helpdesk but now I want to add hyperlinks in the search results that will take you to the actual ticket like so:
http://helpdesk.mycompanydomain.com/index.php?page=viewticket&id=806
<html>
<head><title>Help Desk Search Results</title></head>
<body>
<?php
# declaring the variable to get the input from the user
$name = $_POST["name"];
#declaring the variable to tell php what database to use
$database="tickets";
#Connecting to mysql
mysql_connect ("localhost", "root", "mypassword");
#Selecting the database
@mysql_select_db($database) or die( "Unable to select database");
# Running the query, where the magic happens
$result = mysql_query( "select tickets_tickets.id, tickets_tickets.subject, tickets_tickets.body, tickets_answers.body from tickets_tickets
inner join tickets_answers on tickets_tickets.id = tickets_answers.ticket_id
WHERE tickets_answers.body LIKE '%".$name."%' OR tickets_tickets.body LIKE '%".$name."%'ORDER BY tickets_tickets.id;" )
or die("SELECT Error: ".mysql_error());
#Gives the number of returned records
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
#prints the results as a table
print "<table width=400 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
</body>
</html>
It returns the ticket ID, as well as the subject, question, and replies in the same row.
What I want to do is have a URL for the ticket ID in the ticket ID column of the results table?
Does anyone have any suggestions on how I can acheive this, or can someone point me to some good resources or articles?