Jump to content

search forms with sql


natasha23

Recommended Posts

Hi i am trying to get my search form to work for my database but nothing is displaying, not even the form. It works shows if i just have it as a HTML table. Can someone please tell me where i am going wrong?

 

thanks

 

echo '<form name="shape Test" method="post" action="<'?=$PHP_SELF?'>">';

echo "Seach for: <input type="text" name="find" /> in";

echo "<Select NAME="field">";

echo "<Option VALUE="$Row['colour']">colour</option>";

 

echo "</Select><input type="hidden" name="searching" value="yes" /><input type="submit" name="search" value="Search" />";

echo "</form>";

 

 

(I have the connection to my database above this bit of code.)

Link to comment
https://forums.phpfreaks.com/topic/194200-search-forms-with-sql/
Share on other sites

Ok, I'll go line by line.

 

I don't know what you're trying to accomplish in this line, you probably got a couple things mixed up.

 

echo '<form name="shape Test" method="post" action="<'?=$PHP_SELF?'>">'; // Error on a couple different levels
echo '<form name="shape Test" method="post" action="'.$PHP_SELF.'">'; // Properly escaped

 

 

On your lines after that, you have some escaping errors. If you use double quotes in the php, use single quotes in the HTML, or escape them.

echo "Seach for: <input type="text" name="find" /> in"; // This is an error
echo "Seach for: <input type=\"text\" name=\"find\" /> in"; // This is escaped
echo "Seach for: <input type='text' name='find' /> in"; // This uses single quotes

 

 

On the line that you deal with color, you didn't use an assignment operator:

echo "<Option VALUE="$Row['colour']">colour</option>"; // Error
echo "<Option VALUE=".$Row['colour'].">colour</option>"; // OK in php, not OK in HTML
echo "<Option VALUE='".$Row['colour']."'>colour</option>"; // Shows a single quote in HTML, and is ok in PHP with the double quotes and assignment operator

 

 

On the following lines, just fix your escaping, and then post your code back here if it still doesn't work.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.