 |
| ::: T4VN Statistics ::: |
PHP Scripts : 51
|
PHP Example : 67
|
PHP Tutorials : 21
|
PHP News : 93
|
Total Coupon : 36
|
Other Tutorials :
|
Member : 175
|
Visitor Online : 3
|
Today Visit: 309
|
Total Visitor : 112639
|
Most Online : 31
|
|
|
 |
Count Rows From 2 Tables
Author : jbullard
This code will allow you to select a field from one table and get how many rows are affected by the query in the second table.
| PHP Example : |
|
<?
$goSQL1 = "SELECT your_field1 FROM your_table";
$res1 = @mysql_query($goSQL1,$conn) or die(mysql_error());
while ($row = mysql_fetch_array($res1)) {
$your_field1 = $row['your_field1'];
$goSQL2 = "SELECT your_field2 FROM your_table2 WHERE your_field2 = your_field1";
$res2 = @mysql_query($goSQL2,$conn) or die(mysql_error());
$count1 = mysql_num_rows($res2);
echo "".$your_field1." (".$count1.")";
}
?>
|
|
|
|

|
 |
| ::: Resources ::: |
|
|
| ::: New Templates ::: |
|
| ::: Other Tutorials ::: |
|
|