I use phpMyAdmin , the request itself works there. It is necessary to display in the table the dog, the owner and the type of certificate.

 <? include 'db_connect.php'; $n = mysql_query("SELECT * FROM applications WHERE type ='titul'"); for ($i=0; $i<mysql_num_rows($n); $i++) { echo "<tr>"; $num = mysql_fetch_array($n); $dogs = mysql_query("SELECT * FROM dogs WHERE user_id='$num[user_id]'"); $d = mysql_fetch_array($dogs); $owner = mysql_query("SELECT 'certificate_application.dog_id', 'certificate_application.user_id', 'certificate_application.app_id', 'certificate_application.certificate', 'users.user_name', 'dogs.dog_name' FROM 'certificate_application, users', 'dogs' WHERE 'certificate_application.user_id' = 'users.user_id' AND 'certificate_application.dog_id' = 'dogs.dog_id'"); $d = mysql_fetch_array($owner); echo "<td>".($i+1)."</td>"; echo "<td>".$num[date]."</td>"; echo "<td>".$d[dog_name]."</td>"; echo "<td>".$d[user_surname] ."</td>"; echo "<td>".$d[certificate]."</td>"; // echo "<td>".$num[status]."</td>"; ?> 
  • It is very desirable to describe what it looks like "does not work" with the words of the Russian language. - Ipatiev
  • $dogs = mysql_query("SELECT * FROM dogs WHERE user_id='{$num[user_id]}'"); - ilyaplot
  • When entering the query "SELECT 'certificate_application.dog_id', 'certificate_application.user_id', 'certificate_application.app_id', 'certificate_application.certificate', 'users.user_name', 'dogs.dog_name' FROM 'certificate_application, users', 'dogs' WHERE 'certificate_application.user_id' = 'users.user_id' AND 'certificate_application.dog_id' = 'dogs.dog_id' "in the database displays the desired result, but the site does not display anything and writes that the error is in this query (writes what Warning: mysql_fetch_array (): supplied result mysql is not a valid MySQL result resource) - Irina

1 answer 1

 "SELECT certificate_application.dog_id, certificate_application.user_id, certificate_application.app_id, certificate_application.certificate, users.user_name, dogs.dog_name FROM certificate_application, users, dogs WHERE certificate_application.user_id = users.user_id AND certificate_application.dog_id = dogs.dog_id;" 

Feel the difference? Why do you put quotes where they are not needed? For escaping the names of columns and tables, use the "` "character and not the single quote.

P.S. Only people who learn php from the books of the 90s use mysql_* functions. All progressive humanity uses PDO