Hey guys,
I have a problem with searching for a string within a string. Here's the code I have at the moment:
$query = mysql_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".$db."'") or die(mysql_error());
while($table = mysql_fetch_array($query)){
$checktbl = $table['TABLE_NAME'];
foreach($_POST['fields'] as $f){
$f = substr($f,strpos($f, '.'));
if($checktbl == $f){
$from .= $f.", ";
}}}
$from = substr($from,0,-2);
This should take each table name (gotten from the $query string) and then compare it against $_POST['fields'] which is sent from the previous page. $_POST['fields'] has a string that is made of "tablename"."fieldname". Currently it comes up with an error saying Unknown table 'test' in field list.
Looking at the code now I'm not even sure if it will work how I want it to. For each table name I want to check if it exists in any of the $_POST['fields']. If it does then it will add the table name to the $from string, but only once, otherwise it will move onto the next table name.
Thanks in advance for any help :)