Jump to content

PHP search help


anthonydamasco

Recommended Posts

Hey, I want to search using PHP and Mysql but I know I'm doing this wrong

[code=php:0]
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM joborder WHERE companyname LIKE '%$search%'");
while($r=mysql_fetch_array($result))
{
 
  $companyname=$r["companyname"];
  $posdes=$r["positiondescription"];
  $firstname=$r["firstname"];
  $date=$r["date"];
  $email=$r["email"];
  $id=$r["orderid"];
 
  echo "<table width="534" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="135">Company Name: </td>
    <td width="131">$companyname</td>
    <td width="134">Contact Name: </td>
    <td width="134">$firstname</td>
  </tr>
  <tr>
    <td>Email: </td>
    <td>$email</td>
    <td>Date:</td>
    <td>$date</td>
  </tr>
  <tr>
    <td colspan="4">Order ID Number : $id</td>
  </tr>
  <tr>
    <td colspan="4">Position Description : </td>
  </tr>
</table>";
}
?>
[/code]

I want my variables displayed in that table, what do I have to fix?
Link to comment
Share on other sites

You start your ech with a double quote. But then you also surround the html attributes with double quotes. Anything between your first echo "and the last echo " should be single quotes or escaped. Then the PHP variables will display allright. You should (just 1 line example) write e.g.:
[code]echo "<table width='534' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td width='135'>Company Name: </td>
etc .....
[/code]
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.