I have a MySQL database called "test", in this database there is a table "click". This table has three columns "username", "password" and "click". How to display data from the "click" table on the page if the text entered into a variable matches one of the entries in the "username" column?

Database Connection Code

<? $servername = "localhost"; $database = "test"; $username = "root"; $password = ""; $conn = mysqli_connect($servername, $username, $password, $database); ?> 
  • Connected to the database, then what's the problem? can not write a query on the sample? - teran
  • That's just the same I can not, therefore, wrote here. - tiamenti
  • specify the problem. You do not know the SQL syntax for writing a query, or do not know how to execute it using php? You tried to read the certificate, there are also a bunch of code examples. php.net/manual/ru/mysqli-stmt.execute.php. Here is an example of executing a query with parameters (insert) and then fetching the result. - teran
  • I need that from the table ( pp.userapi.com/c848528/v848528473/188f41/wFp9Fj_f_p8.jpg ) the click value of the user tiamenty is displayed on the page - tiamenti

1 answer 1

Paste this code after your:

 $query = "SELECT click FROM click WHERE username = 'tiamenty'"; $result = mysqli_query($conn, $query); $returned = mysqli_fetch_assoc($result); mysqli_free_result($result); echo $returned['click'];