Jump to content


PHP search help

  • Please log in to reply
2 replies to this topic

#1 anthonydamasco

  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 08 August 2006 - 08:45 PM

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

$result = mysql_query("SELECT * FROM joborder WHERE companyname LIKE '%$search%'");
   echo "<table width="534" border="0" cellspacing="0" cellpadding="0">
    <td width="135">Company Name: </td>
    <td width="131">$companyname</td>
    <td width="134">Contact Name: </td>
    <td width="134">$firstname</td>
    <td>Email: </td>
    <td colspan="4">Order ID Number : $id</td>
    <td colspan="4">Position Description : </td>

I want my variables displayed in that table, what do I have to fix?

#2 ToonMariner

  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 08:48 PM

if you use double quoted string you must escape any double quotes within that string!

so each time you have anything like width="534" you shoudl use width=\"534\"
follow me on twitter @PHPsycho

#3 ronverdonk

  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 08 August 2006 - 10:04 PM

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.:
echo "<table width='534' border='0' cellspacing='0' cellpadding='0'>
    <td width='135'>Company Name: </td>
etc .....

RTFM is an almost extinct art form, it should be subsidized.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users