HI all, how are you ? i need help from you people. This time my problem is that i m running a query inside another query. But, the result that i got is something not exactly what i want. and one problem its only showing the result that is affected by the inside query.
syntaxt is some thing like this
[PHP]$sql = "run some query";
$result = mysql_query($sql);
while($rows= mysql_fetch_array($result))
{
// inside query i access one field name to accesss from other table
$sql2 = query ..
// the problem is the result is showing only those pages which is affected by $sql2 query.
}[/PHP]
i m giving the code below and plz find out the problem [PHP]$sql = "SELECT * FROM telnumbertable";
$result = mysql_query($sql) or die(mysql_error());
//$num_rows = mysql_num_rows($result) or die(mysql_error());
if(mysql_affected_rows()>0)
{
echo "<table width=\"100%\" border=\"0\" cellpadding=\"1\">";
echo "<tr><td>SL No</td><td>Telephone No</td><td>Service Provider</td><td>Authorized Amount</td><td>No. of User</td><td> Detailed</td><td>Update</td><td>Delete</td></tr>";
$i=1;
$no = 1;
while($row = mysql_fetch_array($result))
{
$telNumber = $row['telNumber'];
f$sql3 = mysql_query("SELECT * from userdetails where telNumber = '$telNumber' ") or die (mysql_error());
$rows = mysql_num_rows($sql3) or die(mysql_error());
if($rows>0)
{
$total = $rows;
}
else
{
$total = "No user";
}
if($i%2=="0")
{
$bg = "#808080";
}
else
{
$bg = "#C0C0C0";
}
$id = $row['id'];
echo "<tr bgcolor=$bg>";
echo "<td>00".$no."</td>";
echo "<td>".$row['telNumber']."</td>";
echo "<td>".$row['serProvider']."</td>";
echo "<td>Rs.".$row['authAmount']."/-</td>";
echo "<td><a href=\"user_detailed_by_number.php?mobileID=$id\"> ".$total."</a></td>";
echo "<td><a href=\"view2.php?mobileID=$id\">Detail</a></td>";
echo "<td><a href=\"update.php?id=$id\">Update</a></td>";
echo "<td><a href=\"delete.php?id=$id\">Delete</a></td>";
echo "</tr>";
$i++;
$no++;
}
echo "</table>";
}[/PHP]
please help me