How to make a selection from the database, if the data with the value matches another table, for example, how to display the value of Moscow from the users table, if it matches the other table

<?php if ( get_post_meta( $post->ID, 'cp_street', true) ) : require 'connect.php'; mysql_set_charset( 'utf8' ); $sql_select = "SELECT * FROM users"; $result = mysql_query($sql_select); $row = mysql_fetch_array($result); do { printf ("if (city == '".$row['name']."') { $('#mydiv').html('" .$row['last_name']. " - ".$row['email']."');}" ); } while($row = mysql_fetch_array($result)); endif; ?> 

This is responsible for the sample, the problem is that it displays the entire value

  • Describe the structure of both tables, and which fields in them must match in order for the rows to fit into the selection. - Vladimirov Alexey
  • This is a table of users prnt.sc/d279pc - Vitaly Nosikov
  • I'm happy for the users table, but with which it should match. what's the second table. In general, google "sql join" - Mike
  • The problem is that the data about the city is visible only on the page itself, which is why the script stands, in the database about the city, the words are not words - Vitaly Nosikov

0