MySQL Table Selecting
Enverex
Worcester, UK Icrontian
Been trying for ages but cant get it to work. How do you select multiple tables in MySQL using PHP, my code is as follows -
[PHP]if ($_REQUEST == "all") {$Letter = '123, A, B, C, D, E, F, G, H, I, J, K, L, M, N, I, O, P, Q, R, S, T, U, V, W, X, Y, Z' ;}else{$Letter = $_REQUEST;};
if( !isset($_GET)) {
$SQL="SELECT COUNT(*) AS Total FROM `$Letter`";
$SQL_Result=mysql_db_query($DB_Name, $SQL);
$SQL_Result_Array=mysql_fetch_array($SQL_Result) || die(mysql_error());
$Total=$SQL_Result_Array;
// Create a new SELECT Query with the ORDER BY clause and without the COUNT(*)
$SQL="SELECT * FROM `$Letter` ORDER BY Name";
}else{
$k = $_REQUEST;
// Run The Query Without a Limit to get Total result
$SQL="SELECT COUNT(*) AS Total FROM `$Letter` WHERE Name LIKE $k";
$SQL_Result=mysql_db_query($DB_Name, $SQL);
$SQL_Result_Array=mysql_fetch_array($SQL_Result) || die(mysql_error());
$Total=$SQL_Result_Array;
// Create a new SELECT Query with the ORDER BY clause and without the COUNT(*)
$SQL="SELECT * FROM `$Letter` WHERE Name LIKE $k ORDER BY Name";
};[/PHP]
Its just the "{$Letter =" bit I need to find out, i.e. is there a "select all tables" command, or if not, how do I need to format the table syntax?
Cheers, off to bed now :o gnight,
NS
[PHP]if ($_REQUEST == "all") {$Letter = '123, A, B, C, D, E, F, G, H, I, J, K, L, M, N, I, O, P, Q, R, S, T, U, V, W, X, Y, Z' ;}else{$Letter = $_REQUEST;};
if( !isset($_GET)) {
$SQL="SELECT COUNT(*) AS Total FROM `$Letter`";
$SQL_Result=mysql_db_query($DB_Name, $SQL);
$SQL_Result_Array=mysql_fetch_array($SQL_Result) || die(mysql_error());
$Total=$SQL_Result_Array;
// Create a new SELECT Query with the ORDER BY clause and without the COUNT(*)
$SQL="SELECT * FROM `$Letter` ORDER BY Name";
}else{
$k = $_REQUEST;
// Run The Query Without a Limit to get Total result
$SQL="SELECT COUNT(*) AS Total FROM `$Letter` WHERE Name LIKE $k";
$SQL_Result=mysql_db_query($DB_Name, $SQL);
$SQL_Result_Array=mysql_fetch_array($SQL_Result) || die(mysql_error());
$Total=$SQL_Result_Array;
// Create a new SELECT Query with the ORDER BY clause and without the COUNT(*)
$SQL="SELECT * FROM `$Letter` WHERE Name LIKE $k ORDER BY Name";
};[/PHP]
Its just the "{$Letter =" bit I need to find out, i.e. is there a "select all tables" command, or if not, how do I need to format the table syntax?
Cheers, off to bed now :o gnight,
NS
0
Comments
lol,
NS
I knew that.
BTW, this forum needs smileys on the left of the post reply box dialoge
But thats me.
I'll add your suggestion, thanks Dan
NS
<
MySQL n00b
NS
NS
I still cant figure this out, so i'll give you a bit more info, see if you can give me more of a push in the right direction.
The tables are: `123` and the Letters from A to Z, and the field it needs to be searching is called 'Name' which is all in the database named 'amigagames'.
Any ideas?
NS
http://sqlcourse.com
http://sqlcourse2.com