Hi I have a problem with several of my PHP scripts, they all execute when the page loads. An example is one searches a database but because i have it set to Where table LIKE '%searchterm%' as it execute when it loads it brings up everything in the table, which isn't great. Could anyone tell me how to prevent this? Thanks
Hi here is one of them. It gives all the band names as results. <form method='post'>Band Name: <input type="text" name="BandName" /><input type="submit" value="search" /></form> <?php $result = mysql_query("SELECT * FROM bandsWHERE BandName LIKE '%$BandName%'"); while($row = mysql_fetch_array($result)) { echo $row['BandName'] . " " . $row['Genre']; echo "<br />"; } ?> HTML: Thanks
<form method="post">Band Name: <input type="text" name="BandName" /><input name="search_now" type="submit" value="search" /></form> <?php if (isset($_POST['search_now'])) { $result = mysql_query("SELECT * FROM bands WHERE BandName LIKE '%$BandName%'"); while($row = mysql_fetch_array($result)) { echo $row['BandName'] . " " . $row['Genre']; echo "<br />"; } } ?> PHP: