Reputation: 43
I need to write a PHP script that will print out results from a MySQL database. For example, say I have 9 fields. Field 1 is an auto increasing number, field two is a three digit number.
I need to be able to have a script read, find the matching number (it'll be from a POST), and then display all matching three digit results, and the 7 other fields as well. I am already logged in to the database in this script.
I guess I'm really at a loss of where to begin. How would one start something like this?
Thank you.
Upvotes: 4
Views: 3159
Reputation: 618
Since you are already connected to the database, all you have to do is query the database the iterate through the results. Here is a quick example.
$sql = "SELECT * FROM table_name WHERE field_two = " . (int) $_POST['field_two_input'];
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo $row['field_one'] . ':' . $row['field_two'] . '<br />';
}
Upvotes: 5
Reputation: 4593
Google around searching "php mysql".
For example: http://www.php.net/manual/en/function.mysql-query.php
You should start with some manual for beginners about SQL, PHP, etc.
Upvotes: 1