Jump to content

unexpected T_ELSEIF


gw32

Recommended Posts

Syntax error found: unexpected T_ELSEIF on line 23

<?php
require("config.php");
$result = mysql_query("SELECT name, mics, status, date_format(eventStart, '%M %e %Y') as start, date_format(eventFinish, '%M %e %Y') as end FROM events where status='S' or status='A' order BY eventStart");
$sta=$row['status'];
{		
	echo "<table rules='rows'>
		<tr>
		<th width='50'><font color='yellow' size='1'>MICS</th>
		<th width='200'><font color='yellow' size='1'>Charity</th>
		<th width='125'><font color='yellow' size='1'>Start Date</th>
		<th width='125'><font color='yellow' size='1'>End Date</th>
		</tr>";
while ($row = mysql_fetch_array($result)) {
		if ($sta == "A");
			{
  				echo "<tr>";
			echo "<td><font color='red' size='1'>" . $row['mics'] . "</td>";
  				echo "<td><font color='red' size='1'>" . $row['name'] . "</td>";
  				echo "<td><font color='red' size='1'>" . $row['start'] . "</td>";
  				echo "<td><font color='red' size='1'>" . $row['end'] . "</td>";
  				echo "</tr>";
			}
		elseif ($sta == "S");
			{
			echo "<tr>";
			echo "<td><font color='#ffffff' size='1'>" . $row['mics'] . "</td>";
  				echo "<td><font color='#ffffff' size='1'>" . $row['name'] . "</td>";
  				echo "<td><font color='#ffffff' size='1'>" . $row['start'] . "</td>";
  				echo "<td><font color='#ffffff' size='1'>" . $row['end'] . "</td>";
  				echo "</tr>";
			}
  		}
	echo "</table>";
}
mysql_close($dbh);
?>
[code]

I don't see it.

Thanks

Link to comment
Share on other sites

That worked.

 

Now do I have this

 

$sta=$row['status'];

 

in the correct position?

 

Thanks again

 

I don't see why you have the curly brackets lines 5 and 34 as it's not enclosing any conditions or loops...

 

$sta=$row['status'];
{		// <- HERE
	echo "<table rules='rows'>

 

and

 

	echo "</table>";
} // <- HERE
mysql_close($dbh);

Link to comment
Share on other sites

As written, $sta will be empty. You're trying to assign it a value before $row['status'] is available. Assuming that 'A' and 'S' are the only possible values for that field, something like this would work for you, with less code.

 

while ($row = mysql_fetch_array($result)) {
   $color = $row['status'] == 'A' ? 'red' : 'white';
   echo "<tr>";
   echo "<td><font color='$color' size='1'>" . $row['mics'] . "</td>";
   echo "<td><font color='$color' size='1'>" . $row['name'] . "</td>";
   echo "<td><font color='$color' size='1'>" . $row['start'] . "</td>";
   echo "<td><font color='$color' size='1'>" . $row['end'] . "</td>";
   echo "</tr>";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.