I managed to create a search bar that searches my forum,it searches the categories table then displays the results,however i want to make a link that redirects me to that result found ,for example i search for a category called business and it displays the result but i want the result to have a link such that when i click it it redirects me to that category but i am getting an error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\mysite\captcha2\tut.php on line 43 my code on line 43 is
<td>'.$category_title.="<a href='view_category.php?cid=".$id."' class='cat_links'>".$title." - <font size='-1'>".$description."</font></a>"'</td> </tr>' and this is my search bar code
if(isset($_POST['search'])){ //form submitted, clicked Submit Search $query = strip_tags(mysql_real_escape_string($_POST['query'])); //try to prevent sql injections if(!$query){ //not enterered a query echo 'You must enter a search query!'; }else{ $table = 'categories'; //the table you want to search $row = 'category_title'; //the row in which you want to search $sql = mysql_query("SELECT * FROM `".$table."` WHERE `".$row."` LIKE '%".$query."%'"); //search query if($sql){ //no errors if(mysql_num_rows($sql) == 0){ //No results found. echo 'No results were found for <strong>'.$query.'</strong>'; }else{ //one or more results have been found echo 'We have found <strong>'.mysql_num_rows($sql).'</strong> for <strong>'.$query.'</strong>.<br><br> <table> <tbody> <tr> <td><strong>category_title</strong></td> </tr>'; while($r = mysql_fetch_array($sql)){ //get data of every user where their category_title is like the $query string $category_title = $r["category_title"]; //lets put the part they searched in bold. $category_title = str_ireplace($query, '<strong>'.$query.'</strong>', $category_title); //lets put the part they searched in bold. echo '<tr> <td>'.$category_title.="<a href='view_category.php?cid=".$id."' class='cat_links'>".$title." - <font size='-1'>".$description."</font></a>"'</td> </tr>'; } echo '</tbody></table>'; } }else{ echo 'Sorry, an MySQL error occurred:<br><br>'.mysql_error(); //an error occurred, so echo it } } }else{ //not clicked Submit Search, so echo the form echo '<h3>Search</h3> <br><br> <form method="post"> <label for="q"></label> <input type="text" size="100" name="query" id="q" value="m0nsta."> <input type="submit" name="search" value="Search"> </form>'; } ?>