PHP Help!

From: Date: Mon, 15 Aug 2011 14:21:34 +0000
Subject: PHP Help!
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-11928@lists.php.net to get a copy of this message
Hi, I am having trouble with PHP. When my search box is empty and the submit button is clicked all the data from my database is listed. How can I have it so when the submit button is clicked nothing happens? I am put the code below. Thanks! James [CODE]<html><body>James' New Site<form action="seaside.php" method="post"><input type="text" name="search"><br><input type="submit"></form><hr width="100%"></hr></body></html><?php $search = "%" . $_POST["search"] . "%"; mysql_connect ("", "", ""); mysql_select_db (""); $query = "SELECT name,msg FROM contact WHERE name LIKE '$search'"; $result = mysql_query ($query); if ($result) { while ($row = mysql_fetch_array ($result)) { echo "<br>$row[0]</br>"; echo $row[1]; } }?>[/CODE]

« previous php.webmaster (#11928) next »