$conn = mysql_connect('localhost','root','password');
if ($conn) {
$sql = "SELECT * FROM a, b WHERE a.cat_id = b.cat_id";
$tmp = mysql_query($sql, $conn);
while ($row = mysql_fetch_array($tmp) {
printf("ID: %s Name: %s", $row[0], $row[1]);
}
}
mysql_close($conn);