PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function table_select($orderno)
{
global $table;
$table_select = "SELECT orderno FROM orders WHERE orderno='$orderno'";
$tq = mysql_query($table_select) or die ("Query 1:$table_select Failed".mysql_error());
if (mysql_num_rows($tq)>0)
{
$table = 'orders';
echo '1<br />';
return;
}
$table_select = "SELECT orderno FROM orders_main WHERE orderno='$orderno'";
$tq = mysql_query($table_select) or die ("Query 2:$table_select Failed".mysql_error());
if (mysql_num_rows($tq)>0)
{
$table = 'orders_main';
echo '2<br />';
return;
}
$table_select = "SELECT orderno FROM orders_trash WHERE orderno='$orderno'";
$tq = mysql_query($table_select) or die ("Query 3:$table_select Failed".mysql_error());
if (mysql_num_rows($tq)>0)
{
$table = 'ordertrash';
echo '3<br />';
return;
}
$table_select = "SELECT orderno FROM orders WHERE orderno='$orderno'";
$tq = mysql_query($table_select) or die ("Query 4:$table_select Failed".mysql_error());
if (mysql_num_rows($tq)>0)
{
$table = 'orders_trash';
echo '4<br />';
}
}
//call the function
table_select($GET['number']);
It used to work and set the table as $table, but for some reason it doesn't now echo anything out as a result. Any ideas?
Lol it's always something simple , thanks for that.
Still having a problem though. When i run the file on it's own in the browser it works fine, but when i have it included into an index i get a blank section where the file is.
//table select function table_select($orderno) { global $table; $table_select = "SELECT orderno FROM orders WHERE orderno='$orderno'"; $tq = mysql_query($table_select) or die ("Query 1:$table_select Failed".mysql_error()); if (mysql_num_rows($tq)>0) { $table = 'orders'; echo '1
'; return; } $table_select = "SELECT orderno FROM orders_main WHERE orderno='$orderno'"; $tq = mysql_query($table_select) or die ("Query 2:$table_select Failed".mysql_error()); if (mysql_num_rows($tq)>0) { $table = 'orders_main'; echo '2
'; return; } $table_select = "SELECT orderno FROM orders_trash WHERE orderno='$orderno'"; $tq = mysql_query($table_select) or die ("Query 3:$table_select Failed".mysql_error()); if (mysql_num_rows($tq)>0) { $table = 'ordertrash'; echo '3
'; return; } $table_select = "SELECT orderno FROM orders WHERE orderno='$orderno'"; $tq = mysql_query($table_select) or die ("Query 4:$table_select Failed".mysql_error()); if (mysql_num_rows($tq)>0) { $table = 'orders_trash'; echo '4
'; } }
Fatal error: Call to undefined function: table_select() in /homepages/40/d108546070/htdocs/test/sec_test/admin/orders/ordershow.php on line 5
outputted to the browser. It seems to be showing the function file as text and not as code, which is why the function is undefined, but i can't see why.
If i remove the function and manually set $table to 'orders_main', it works fine.