[thelist] php/mysql get next two records
Mark Groen
markgroen at gmail.com
Sun Feb 6 19:19:26 CST 2005
this is probably really simple but... could some enlighten me to
getting the next two records (next, after that) following the first
one (now playing) to be displayed?
$myHour = date("H");
$myDay = date("l");
$nowPlaying = 0;
$query = "SELECT id,title,dj,show_day,show_start,show_end FROM schedule ";
$query .= "WHERE time_format(show_start,'%H') = '$myHour'";
$mysql_result = mysql_query($query, $mysql_link);
if($row = mysql_fetch_row($mysql_result))
{ $id = $row[0];
$title = $row[1];
$dj = $row[2];
$show_day = $row[3];
$show_start = $row[4];
$show_end = $row[5];
print("<h1>now playing</h1>");
if($show_day == $myDay)
{
print("<strong>");
$str = ("2005-02-07" . " $show_start");
if (($timestamp = strtotime($str)) === -1) {
echo "nothing on right now";
} else {
echo date('g:i', $timestamp);
}
print(" - ");
$str2 = ("2005-02-07" . " $show_end");
if (($timestamp = strtotime($str2)) === -1) {
echo "nothing on right now";
} else {
echo date('g:i', $timestamp);
}
print("</strong<br>$title");
}
$nowPlaying++;
if($nowPlaying == 1)
{print("<h1>next</h1>");
print("<strong>$show_start - $show_end ::</strong><br>");
print("$title");
}
// and then one more listing,
//format now playing, next as below
//after that
//2:00 - 2:10 ::
//Legal Alert
}
txs, slighty addled,
Mark
More information about the thelist
mailing list