[Solved] Query MySQL on PHP [closed]


try to remove the simple quotes in your printf: $row['id_region'] becames $row[id_region] but I suggest you this to be sure:

echo '<td>'.$row['id_region'].'</td>';

Also, please consider using mysqli instead of mysql, as it’s deprecated

<?php

$dbhost="............";
$dbuser="........";
$dbpass=".......";
$dbname="db_site";
$my = new Mysqli($dbhost, $dbuser, $dbpass, $dbname);

?>
<h4><center>Title</center></h4>
<table border="2" cellspacing='0' cellpadding='0'>
<tr>
<td>id</td>
<td>id_site</td>
<td>id_mast</td>
<td>name_site</td>
<td>address</td>
<td>types</td>
<td>longtitude</td>
<td>latitude</td>
<td>altitude</td>
<td>id_region</td>
</tr>
<?php

// create a db connexion
$sql="SELECT * FROM site, region WHERE site.id_region= region.id_region LIMIT 2;";
// make the query
$stmt = $my->query($sql);
// fetch the results, display them as you want
while($row = $stmt->fetch_assoc())
{
  echo '<tr>';
  echo '<td>'.$row['id'].'</td>';
  echo '<td>'.$row['id_site'].'</td>';
  echo '<td>'.$row['id_mast'].'</td>';
  echo '<td>'.$row['name_site'].'</td>';
  echo '<td style="width:100;">'.$row['address'].'</td>';
  echo '<td style="width:100;">'.$row['types'].'</td>';
  echo '<td>'.$row['longtitude'].'</td>';
  echo '<td>'.$row['latitude'].'</td>';
  echo '<td>'.$row['altitude'].'</td>';
  echo '<td>'.$row['id_region'].'</td>';
  echo '</tr>';
}
echo '</table>';

0

solved Query MySQL on PHP [closed]