<?php $get_total = mysql_fetch_array(mysql_query("SELECT 'total' FROM 'table_name' WHERE itsme='itsme';")); ?> PHP: Now its easy as stated above I would just call $get_total[0] to display the results. However if I wanted to get the total from multiple tables table_name1 table_name2 table_name3 etc etc there is over 100 tables. And return the total combined amount How could I do this? I want to make sure it wouldnt put to much of a load on the server to process the query for display. Thanks, TJ
You use a JOIN command, which lets your query multiple tables in a single query provided there is a way to identify which rows to pull. Example: Table 1 has 4 columns (ID, Name, Date, and Email). ID is a unique identifier. Table 2 has 3 columns (email, phonenumber, and city). Let's say you want to pull all this information, you can do it in a single query by joining on the Email field since it's in both tables: SELECT t1.ID, t1.Name, t1.Date, t1.Email, t2.City, t2.PhoneNumber FROM firsttable t1 LEFT JOIN secondtable t2 ON t1.Email = t2.email ORDER by t1.Date Code (markup): That will join the two tables together on the Email field and display the results chronologically.
itsme would be the unique identifier in all the tables. all the tables have the same stored information its a gaming site with different rounds thus table_name1 (round 1) table_name2 (round 2) so on and so forth There has to be a better way as there will be more and more rounds and in order to use the example you provided I would haev to edit it after each round without auto generating the next table # $xyz=1; $xyz++ Something of this nature should be able to be used to generate what is needed for a one time edit that will auto generate and pull the next table once it exists. TJ
Well you could do a query of "show tables" to get a list of all the tables, do a regex on the list to find the ones with a similar name, then pull out the numeric variable from each of them and take the highest value. Then use that to identify the table in question. It would just take 2 mysql queries, about probably about 25 lines of PHP code.