<?php
mysql_connect( ':/Applications/MAMP/tmp/mysql/mysql.sock',$u, $p);
mysql_query('create database if not exists wordTest');
mysql_select_db('wordTest');
mysql_query('create table if not exists test (word varchar(255) primary key)') or die(mysql_error());
mysql_query('create table if not exists test2 (word varchar(255))') or die(mysql_error());
foreach(array('banana','mango','apple') as $fruit):
foreach(array('test', 'test2') as $table):
@mysql_query("insert into $table (word) values('$fruit')");
endforeach;
endforeach;
foreach(array('test', 'test2') as $table):
echo "<hr/>Table $table <br/>";
$result = mysql_query("select word from $table") or die(mysql_error());
while($row = mysql_fetch_assoc($result)):
echo $row['word'] . '<br/>';
endwhile;
endforeach;