php - How to display a certain details from database -
i have code search in mysql , working when run , entered account number display accounts in database want display details account number inquire on.
what should change or add? don't know
<?php echo "<h2>search results:</h2><p>"; //if did not enter search term give them error if ($find == "account_number") { echo "<p>you forgot enter search term!!!"; exit; } // otherwise connect our database mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // perform bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //now search our search term, in field user specified $data = mysql_query("select account_number, name, balance memaccounts id like'%$find%'"); //and display results while($result = mysql_fetch_array( $data )) { echo $result['account_number']; echo " "; echo $result['name']; echo "<br>"; echo $result['balance']; echo "<br>"; echo "<br>"; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "sorry, can not find entry match query...<br><br>"; } //and remind them searched echo "<b>searched for:</b> " .$find; //} ?>
$data = mysql_query("select account_number, name, balance memaccounts account_number = '" . trim($find) . "' "); 1.where ac no.
suggestion : use mysqli_*
Comments
Post a Comment