Dear,
I have 2 tables,
first table
name: directory
fields: id, name, surname num1, operator1 (operator id from operator table), num2, operator2 (operator id from operator table).
(num2 and operator2 may be left empty)
second table.
name: operator
fields: id, operator
I made a page to display the data from these two tables and I have a small problem with select query (line 8) because when I write this part AND directory.operator2 = operator.id, the page didn't display any data. Anyone help me to solve this problem please?
<?php
require("../headerloggedin.php");
?>
<div id="content">
<?php
$userid = $_SESSION["userid"];
$query = "SELECT * FROM directory, operator WHERE directory.operator1 = operator.id AND directory.operator2 = operator.id" ;
$result = $db->query($query);
while ($row = mysql_fetch_array($result))
{
?>
<table>
<tr>
<td>Name:</td>
<td><?php echo $row["name"];?></td>
</tr>
<tr>
<td>Surname:</td>
<td><?php echo $row["surname"]; ?></td>
</tr>
<tr>
<td>Mobile Number:</td>
<td><?php echo $row["num1"]; ?></td>
</tr>
<tr>
<td>Operator:</td>
<td><?php echo $row["operator"]; ?></td>
</tr>
<tr>
<td>Mobile Number 2:</td>
<td><?php echo $row["num2"]; ?></td>
</tr>
<tr>
<td>Operator 2:</td>
<td><?php echo $row["operator"]; ?></td>
</tr>
</table>
<br />
<?php
}
?>
<br />
<a href="../indexloggedin.php">Go to main menu.</a>
</div>
<?php require("../footerloggedin.php"); ?>