I'm trying to search for values from two different tables and combine the values. I need one more search form, and a way to multiply the values. I am a beginner.
By the way, I'm not getting any value; just "No records matching your query were found." The DB is fine!
Here's my code:
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "mysql");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$search1 = @$_GET['Valorm2'];
$search2 = @$_GET['M2'];
$sql = "SELECT * FROM porteval, squarefeet WHERE Freguesia = '$search1' AND M2 = '$search2'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>ADVISED VALUE </th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Id'] . "</td>";
echo "<td>" . $row['Pais'] . "</td>";
echo "<td>" . $row['Distrito'] . "</td>";
echo "<td>" . $row['Freguesia'] . "</td>";
echo "<td>" . $row['Valorm2'] . "</td>";
echo "<td>" . $row['Valorm2'] * 100 . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
</body>
</html>