jamesyrawr Posted January 11, 2011 Share Posted January 11, 2011 I have a photo album style gallery to build and i'm finding it dificult to list all the table names (these are names of photo albums) and then enter the data into a seperate query for each album name (these will change often so i cant keep updating the file as normal. this will then post all the data to the xml file and show the set of photos in the individual albums in a flash file. can anyone help me where im going wrong at all? <?php $dbname = 'cablard'; if (!mysql_connect('localhost', 'cablard', '')) { echo 'Could not connect to mysql'; exit; } $sql = "SHOW TABLES FROM $dbname"; $result = mysql_query($sql); if (!$result) { echo "DB Error, could not list tables\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { echo "Table: {$row[0]}\n"; } mysql_free_result($result); $query = "SELECT * FROM photo ORDER BY id DESC"; $result2 = mysql_query ($query) or die ("Error in query: $query. ".mysql_error()); while ($row = mysql_fetch_array($result2)) { echo " <image> <date>".$row['date']."</date> <title>".$row['title']."</title> <desc>".$row['description']."</desc> <thumb>".$row['thumb']."</thumb> <img>".$row['image']."</img> </image> "; } ?> Thanks James Link to comment https://forums.phpfreaks.com/topic/224024-mysql-select-all-tables-then-post-each-table-name-in-a-different-query/ Share on other sites More sharing options...
BlueSkyIS Posted January 11, 2011 Share Posted January 11, 2011 i would not use a different table for each album. as you've seen, that makes things more difficult and less efficient. just use one table, with a unique identifier linking to a second table containing information for each album. Link to comment https://forums.phpfreaks.com/topic/224024-mysql-select-all-tables-then-post-each-table-name-in-a-different-query/#findComment-1157686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.