PHP and MySQL - print rows matching column value

I need to write a PHP script that will print the results from a MySQL database. For example, let's say I have 9 fields. Field 1 is a number that automatically increases the number, field two is a three-digit number.

I need to have a script reading, find the corresponding number (it will be from POST), and then display all the relevant three-digit results and 7 other fields. I have already registered in the database in this script.

I think I'm really losing the beginning. How can I start something like this?

Thanks.

+4
source share
2 answers

Since you are already connected to the database, all you have to do is query the database, iterate the results. Here is a brief 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 />'; } 
+5
source

Google around the search for "php mysql".

For example: http://www.php.net/manual/en/function.mysql-query.php

You should start with a beginner's guide on SQL, PHP, etc.

+1
source

Source: https://habr.com/ru/post/1309287/


All Articles