Assistance with Code for access to MySQL
Not to inconvenience anyone unnecessarily, but, I have done much searching on the internet and still cannot find the exact answer. There are MANY similar examples, but nothing exact (Must be because my coding is pretty ... bad)
To be brief, I have a MySQL Db and all the relevant tables (plus) scripts for view all, edit & delete records..... What I don't have is a 'search' page using a text box, which can search my Db using a specific "13" digit number like (6125478215017).
The scripts that I have all work when searching for the "First name" or "Last name" but I really need the search based on a number. I would be happy with a simple php page. If anyone has code for this, I would be VERY HAPPY.
SORRY, CODE IS:
?php
/* call this script "advs.php" */
if(!$c) {
?>
<form action="advs.php?c=1" method=POST>
<b>Find Results with: </b><br>
Any of these words: <input type="text" length=40 name="any"> <br>
All of these words: <input type="text" length=40 name="all"> <br>
None of these words: <input type="text" length=40 name="none"> <br>
<input type="submit" value="Search">
</form>
<?
} else if($c) {
MySQL_connect("localhost", "afr", "kiap");
MySQL_select_db("afrdatabase");
if((!$all) || ($all == "")) { $all = ""; } else { $all = "+(".$all.")"; }
if((!$any) || ($any == "")) { $any = ""; }
if((!$none) || ($none == "")) { $none = ""; } else { $none = "-(".$none.")"; }
$query = "
SELECT *,
MATCH(title, story) AGAINST ('$all $none $any' IN BOOLEAN MODE) AS score
FROM users
WHERE MATCH(title, story) AGAINST ('$all $none $any' IN BOOLEAN MODE)";
$artm1 = MySQL_query($query);
if(!$artm1) {
echo MySQL_error()."<br>$query<br>";
}
echo "<b>Article Matches</b><br>";
if(MySQL_num_rows($artm1) > 0) {
echo "<table>";
echo "<tr><td>Score </td><td>Title </td><td>Body</td></tr>";
while($artm2 = MySQL_fetch_array($artm1)) {
$val = round($artm2['score'], 3);
$val = $val*100;
echo "<tr><td>$val</td>";
echo "<td>{$artm2开发者_C百科['title']}</td>";
echo "<td>{$artm2['body']}</td></tr>";
}
echo "</table>";
}
else {
echo "No Results were found in this category.<br>";
}
echo "<br>";
}
?>
send a query like SELECT first_name, last_name, thirteen_digit_number FROM mytable WHERE thirteen_digit_number = 6125478215017
[updated] so if you want the whole row, use SELECT *
. it appears you already know how to format the result into HTML, so what more do you need from the community?
have you tried LIKE '%612547%'
SELECT * FROM `tbl_number` WHERE `number` LIKE '%612547%'
Need more specifics for better answer.
精彩评论