My DB looks like this
paynumber fullname linemanager
12345 John Smith Jack Jones
12346 Joe Bloggs Andy Smith
I want it so if you enter 12345
into a textfield it will return John Smith in the same text field
I've tried so many mysql_queries I don't know which one to post!
I'm not looking for full code, as I'm not bad at that, but please point me in the right direction!
Cheers!
<?php
$mysql_host = "host";
$mysql_username = "user";
$mysql_password = "pass";
$link = mysql_connect("$mysql_host", "$mysql_username", "$mysql_password");
mysql_select_db("dbname",$link);
$pay_number=intval($_POST["pay_number"]);
$result = mysql_query($link,"SELECT fullname from officers where paynumber=$pay_number");
echo $result;
?>
SELECT fullname from myTable where paynumber=12345
What's so tough about it? Then you can display it anywhere you like. Can add a little bit of AJAX to grab the result and show in the same field.
EDIT:
Lets say your field on your HTML form was named pay_number
and form method was POST
Then in your PHP processing code you could do
$pay_number=intval($_POST["pay_number"]);
$query="SELECT fullname from myTable where paynumber=$pay_number";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.