views:

164

answers:

2

Hello,

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.

A: 

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.

Riho
A: 

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 />';
}
Todd
By god, that worked better than I had imagined. Great job and thank you so much for your time.I'll tweak the output - again, incredible. Thank you.
Michael