Zephyris Posted February 6, 2008 Share Posted February 6, 2008 Like this: section1_news(id, title, msg, datetime) section2_news(id, title, msg, datetime) like: $result = mysql_query("SELECT * FROM section1_news, section2_news"); but like by datetime and LIMIT of 5 rows. outputing the most recent news from the combined two tables.. displaying a max of 5 results. Link to comment https://forums.phpfreaks.com/topic/89670-how-to-use-two-tables-at-the-same-time/ Share on other sites More sharing options...
haku Posted February 6, 2008 Share Posted February 6, 2008 If both your tables have the exact same columns, they should be in one table. Just add another column to differentiate between the two sets of data. For example, if you have a table called Japanese news, and a table called English news, and the column names are exactly the same, you should just use one table called news, then add an extra column called country, filling it in with the applicable country from which the news came from. Then when you are doing your query, you set your query conditions and leave out any reference to country, and it will bring back all news. Link to comment https://forums.phpfreaks.com/topic/89670-how-to-use-two-tables-at-the-same-time/#findComment-459475 Share on other sites More sharing options...
rameshfaj Posted February 6, 2008 Share Posted February 6, 2008 I dont understand your problem,is it in query or what?If it is in query then ucan use more than one table at a time using joins. Link to comment https://forums.phpfreaks.com/topic/89670-how-to-use-two-tables-at-the-same-time/#findComment-459484 Share on other sites More sharing options...
Zephyris Posted February 6, 2008 Author Share Posted February 6, 2008 my test script is basicly <?php // Get Gaming Headlines $result = mysql_query("SELECT * FROM `gaming_news`, `community_news`"); while($row = mysql_fetch_array($result) ){ echo("<td class='10whitebold'>" . ($row['title']) . "</td>"); } ?> only displays community news Link to comment https://forums.phpfreaks.com/topic/89670-how-to-use-two-tables-at-the-same-time/#findComment-459493 Share on other sites More sharing options...
hamza Posted February 6, 2008 Share Posted February 6, 2008 <?php // Get Gaming Headlines $result = mysql_query("SELECT * FROM `gaming_news`, `community_news`"); while($row = mysql_fetch_array($result) ){ echo("<td class='10whitebold'>" . ($row['title']) . "</td>"); } ?> Dear you are just using $row['title'] title to show the title from two pages you are not mentioning the anyother thing to show you like date or other try to do like this while($row = mysql_fetch_array($result) ){ echo("<td class='10whitebold'>" . ($row['title']) . "</td>"); echo("<td class='10whitebold'>" . ($row['news']) . "</td>"); echo("<td class='10whitebold'>" . ($row['date']) . "</td>"); or any other coulmn } if you still not able to do it let me know ............................... Link to comment https://forums.phpfreaks.com/topic/89670-how-to-use-two-tables-at-the-same-time/#findComment-459539 Share on other sites More sharing options...
Zephyris Posted February 6, 2008 Author Share Posted February 6, 2008 Nope, no go. It's only taking the data from one table. Only community news are coming out and none from the gaming news are outputing.. Link to comment https://forums.phpfreaks.com/topic/89670-how-to-use-two-tables-at-the-same-time/#findComment-459754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.