I search about the code for retrieving data from database when the retrieve button was click. But I canít find any codes that similar in my situation.

Here is the flow of my system. I have plt_no and a retrieve button. The retrieve button is to check if the plt_no is already exist or not if it is already exist the data from the database will appear in the text area/textbox and if the plt_no did not exist thereís a message that the id number did not exist and I can input data in the textboxes.


I have an idea of using this code:
This code is to check if the Retrieve button is click and the plt_no is the data which the retrieve depend on. Like for example the user put plt_no 111 and when the user click the Retrieve button, if the 111 is already exist the data will appear in the textboxes but if not thereís a message appear saying the plt no did not exist.

Code:
if(isset($_POST['Retrieve']))
$plt_no = $_POST['plt_no'];



And I have search code for retrieving data:

PHP Code:
 
<?php 
 
// Connects to your Database 
 
mysql_connect("your.hostaddress.com""username""password") or die(mysql_error()); 
 
mysql_select_db("Database_Name") or die(mysql_error()); 
 
$data mysql_query("SELECT * FROM friends WHERE pet='Cat'"
 or die(
mysql_error()); 
 Print 
"<table border cellpadding=3>"
 while(
$info mysql_fetch_array$data )) 
 { 
 Print 
"<tr>"
 Print 
"<th>Name:</th> <td>".$info['name'] . "</td> "
 Print 
"<th>Color:</th> <td>".$info['fav_color'] . "</td> "
 Print 
"<th>Food:</th> <td>".$info['fav_food'] . "</td> "
 Print 
"<th>Pet:</th> <td>".$info['pet'] . " </td></tr>"
 } 
 Print 
"</table>"
 
?>


I attach my full code.

My problem is how can I used that code and if that code is the code I need to used for retrieving data.



I have an idea but i am luck of knowledge in coding

Any help is highly appreciated I ma willing to learn and share

Thank you
Attached Files
File Type: txt retrieve.txt (12.8 KB, 3 views)