MySQL Forums
Forum List  »  PHP

echo names from multiple tables
Posted by: Martin Caestecker
Date: February 12, 2012 03:37PM

Greetings all,

I have a database full of events and info about them. What I'm trying to do is make a page that displays the names of Upcoming Events (within the next 30 days). Below is the code I've used to display the upcoming events from just one table.

Is it possible to make this script work if I wanted to call the names of events from more than one table and stick them all in the same echoed list?

$today = date("Y-m-d");
$onemonth = date("Y-m-d", strtotime("+1 months"));

$result = mysql_query("SELECT name FROM jazz WHERE date BETWEEN '$today' AND '$onemonth' ORDER BY date") or die(mysql_error());
$numrows = mysql_num_rows($result); //Check to see if tables are empty

echo "
<p align=\"center\">Events:</p>
if($numrows == 0){
echo "<p align=\"center\"><em><b>There are currently no events for this performing group. Please check back later.</b></em></p>";

while($row = mysql_fetch_array($result))
echo "<p align=\"center\"><a href=\"#". $row['name'] ."\" class=\"singleredA\">&diams; ". $row['name'] ." &diams;</a></p>";

Thanks for your help


Options: ReplyQuote

Written By
echo names from multiple tables
February 12, 2012 03:37PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.