this is a page from an app that i took a break from a few weeks ago-- largely in part due to the trouble i'm having w/ this page. i've put a lot of time into trying to get it to work right, but there is obviously something very basic yet essential i'm missing here. i hope that if you find it you might be able suggest something for me to study so i don't make the same mistake again. is it my interpretatioin of the if / else function? thanks!
<?php
$artid = $_GET['var'];
$var2 = $_GET['var2'];
global $artid;
global $var2;
$datesoutput = '';
$datesoutput2 = '';
$datesoutput3 = '';
$formatted_date = '';
$conn = mysql_connect("localhost", "private", "private") or die(mysql_error());
mysql_select_db("cb_shows1", $conn) or die(mysql_error());
$checkinids = "SELECT show_date FROM concerts WHERE $artid IN (artist_id1, artist_id2, artist_id3)";
$checkinres = mysql_query($checkinids, $conn) or die(mysql_error());
$checkinnum = mysql_num_rows($checkinres) or die(mysql_error());
if ($checkinnum == 0 ) {
echo $checkinres;
echo "Sorry, no Concerts Scheduled for $var2";
} else if ($checkinnum >= 1); {
$htmlblock = "<h2>Performance Dates Scheduled:";
function getdates() {
global $conn;
$seldates = "SELECT DATE_FORMAT(show_date, '%W, %M %D, %Y') AS formatted_date FROM concerts where artist_id1 =$_GET[var] order by show_date";
$datesres = mysql_query($seldates, $conn) or die(mysql_error());
return $datesres;
}
function getdates2() {
global $datesres2;
global $conn;
$seldates2 = "SELECT DATE_FORMAT(show_date, '%W, %M %D, %Y') AS formatted_date FROM concerts where artist_id2 =$_GET[var] order by show_date DESC";
$datesres2 = mysql_query($seldates2, $conn) or die(mysql_error());
return $datesres2;
}
function getdates3() {
global $datesres3;
global $conn;
$seldates3 = "SELECT DATE_FORMAT(show_date, '%W, %M %D, %Y') AS formatted_date FROM concerts where artist_id3 =$_GET[var] order by show_date DESC";
$datesres3 = mysql_query($seldates3, $conn) or die(mysql_error());
return $datesres3;
}
$datelist1 = getdates();
$datelist2 = getdates2();
$datelist3 = getdates3();
$datesArray1['formatted_date'] = '';
while ($datesArray1 = mysql_fetch_array($datelist1)) {
$datesoutput = $datesArray1['formatted_date'].=" $datesoutput ";
}
while ($datesArray2 = mysql_fetch_array($datelist2)) {
$datesoutput2 = $datesArray2['formatted_date'].=" $datesoutput2 ";
}
while ($datesArray3 = mysql_fetch_array($datelist3)) {
$datesoutput3 = $datesArray3['formatted_date'].=" $datesoutput3 ";
}
$datesblock = $datesoutput." ".$datesoutput2." ".$datesoutput3
}
?>
<html>
<head>
<title>List of performance dates for<?php echo $var2; ?></title>
<link rel="stylesheet" type="text/css" href="css/php.css" />
</head>
<body>
<?php
echo $htmlblock;
echo "$datesblock<br>";
?>
</body>
</html>
i have actually applied another level of normalization to the database which serves this app, but i think i should figure out what's going wrong here before i start to route my data to and from my new table. thanks again!