Jump to content

[SOLVED] need help to display search results


cs1h

Recommended Posts

Hi,

 

I have written a search script for my database and now I want it to display the results in identicle tables, I have tried to do this my self but I am new to php and not very sure what i am doing. Does anyone know how I could edit this script to do this.

 

<?

$targetb = $_POST['menuFilesDMA'];
$targetb = str_replace(' ','_', $targetb);

mysql_connect("localhost","adder","clifford"); 


mysql_select_db("real") or die("Unable to select database"); 

$keywords = preg_split("/[\s,]+/", trim($_POST['keyword']));
$sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($targetb) . "' AND type='" . mysql_real_escape_string($_POST['Type']) . "' AND Abstract LIKE '%$keyword%'";

$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == 0) {
echo "No results please try a different <a href=asearch.html>search</a>.";
} else {
while($row = mysql_fetch_array($result)) {
$Country = $row['country']; 
$Type = $row['type'];
$More = $row['id'];
$Title = $row['Title'];
$Abs = $row['Abstract'];
echo "<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="14" height="28" background="line_left_corner_top.png"> </td>
    <td height="28" colspan="4" background="line_top.png"> </td>
    <td height="28" background="line_right_corner_top.png"> </td>
  </tr>
  <tr>
    <td width="14" rowspan="3" background="line_left.png"> </td>
    <td width="290" height="21"><span class="Large_Blue">$Title</span></td>
    <td width="114" height="21"><img src="stars_five.png" width="114" height="21" /></td>
    <td width="14"> </td>
    <td width="128" height="128" rowspan="3"><<img src="/searchthumbs/$Country$Type.png" width="128" height="128" /></td>
    <td width="14" rowspan="3" background="line_right.png"> </td>
  </tr>
  <tr>
    <td height="86" colspan="2"><span class="Small_Black">$Abs</span></td>
    <td width="14"> </td>
  </tr>
  <tr>
    <td width="290" height="19" align="left" valign="bottom"><span class="style5">>></span> <span class="style7"><a href=asearcher.php?text=$More&Submit=Submit>Read More</a> </span> <span class="style5">>></span></td>
    <td width="114" height="19" align="left" valign="bottom"><span class="Small_Grey">12/09/2007</span></td>
    <td width="14"> </td>
  </tr>
  <tr>
    <td width="14" height="19" background="line_left_corner.png"> </td>
    <td height="28" colspan="4" background="line_base.png"> </td>
    <td width="14" height="19" background="line_right_corner.png"> </td>
  </tr>
</table>";

}
}
?> 

 

The script at the moment also comes up with the error,

 

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in D:\Inetpub\vhost\myroho.com\httpdocs\absearch.php on line 25

 

which I also don't know how to solve.

 

Any help is much appriciated,

 

Cheers,

Colin

Link to comment
Share on other sites

change

echo "<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="14" height="28" background="line_left_corner_top.png"> </td>
    <td height="28" colspan="4" background="line_top.png"> </td>
    <td height="28" background="line_right_corner_top.png"> </td>
  </tr>
  <tr>
    <td width="14" rowspan="3" background="line_left.png"> </td>
    <td width="290" height="21"><span class="Large_Blue">$Title</span></td>
    <td width="114" height="21"><img src="stars_five.png" width="114" height="21" /></td>
    <td width="14"> </td>
    <td width="128" height="128" rowspan="3"><<img src="/searchthumbs/$Country$Type.png" width="128" height="128" /></td>
    <td width="14" rowspan="3" background="line_right.png"> </td>
  </tr>
  <tr>
    <td height="86" colspan="2"><span class="Small_Black">$Abs</span></td>
    <td width="14"> </td>
  </tr>
  <tr>
    <td width="290" height="19" align="left" valign="bottom"><span class="style5">>></span> <span class="style7"><a href=asearcher.php?text=$More&Submit=Submit>Read More</a> </span> <span class="style5">>></span></td>
    <td width="114" height="19" align="left" valign="bottom"><span class="Small_Grey">12/09/2007</span></td>
    <td width="14"> </td>
  </tr>
  <tr>
    <td width="14" height="19" background="line_left_corner.png"> </td>
    <td height="28" colspan="4" background="line_base.png"> </td>
    <td width="14" height="19" background="line_right_corner.png"> </td>
  </tr>
</table>";

to

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <td width=\"14\" height=\"28\" background=\"line_left_corner_top.png\"> </td>
    <td height=\"28\" colspan=\"4\" background=\"line_top.png\"> </td>
    <td height=\"28\" background=\"line_right_corner_top.png\"> </td>
  </tr>
  <tr>
    <td width=\"14\" rowspan=\"3\" background=\"line_left.png\"> </td>
    <td width=\"290\" height=\"21\"><span class=\"Large_Blue\">$Title</span></td>
    <td width=\"114\" height=\"21\"><img src=\"stars_five.png\" width=\"114\" height=\"21\" /></td>
    <td width=\"14\"> </td>
    <td width=\"128\" height=\"128\" rowspan=\"3\"><<img src=\"/searchthumbs/$Country$Type.png\" width=\"128\" height=\"128\" /></td>
    <td width=\"14\" rowspan=\"3\" background=\"line_right.png\"> </td>
  </tr>
  <tr>
    <td height=\"86\" colspan=\"2\"><span class=\"Small_Black\">$Abs</span></td>
    <td width=\"14\"> </td>
  </tr>
  <tr>
    <td width=\"290\" height=\"19\" align=\"left\" valign=\"bottom\"><span class=\"style5\">>></span> <span class=\"style7\"><a href=asearcher.php?text=$More&Submit=Submit>Read More</a> </span> <span class=\"style5\">>></span></td>
    <td width=\"114\" height=\"19\" align=\"left\" valign=\"bottom\"><span class=\"Small_Grey\">12/09/2007</span></td>
    <td width=\"14\"> </td>
  </tr>
  <tr>
    <td width=\"14\" height=\"19\" background=\"line_left_corner.png\"> </td>
    <td height=\"28\" colspan=\"4\" background=\"line_base.png\"> </td>
    <td width=\"14\" height=\"19\" background=\"line_right_corner.png\"> </td>
  </tr>
</table>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.