Jump to content

echo html in php


fife

Recommended Posts

Hi im trying to echo out some html within php based on an if statement.  Basically if you the is part of a club within a list item list the clubs, if they are not echo none within the list.  Here is the code and below will be the error from the server.


   <?php 
					// Query for finding out if the signed in user is part of any clubs and then display them here.
					$qMyClub = "SELECT clubID, name FROM clubs WHERE memberID = ".$User['memberID']."";
					$rMyClub = mysql_query($qMyClub);
					$NumClubs = mysql_num_rows($rMyClub);
					if ($NumClubs>=1) { 
					 while($Clubs = mysql_fetch_assoc($rMyClub)){
					  echo"<li>My Clubs
                        	<ul>
                            <li><a href=\"members/myclub.php?club='$Club['clubID']'\">$Club['name']</a></li>
                            </ul>
                        </li>";						 
					}
					else ($NumClubs==0) {

					echo"
					 <li>My Clubs
                        	<ul>
                            <li>None</li>
                            </ul>
                        </li>";	
					}
					 }
                        ?>

and the error;

 

[error] [client ] PHP Parse error:  syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/index.php on line 78, referer:

 

its referencing to the following line;

<li><a href=\"members/myclub.php?club='$Club['clubID']'\">$Club['name']</a></li>

 

I dont understand php enough to fix this can anyone help?

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

thank you but now the error has moved down a few lines;

 

PHP Parse error:  syntax error, unexpected T_ELSE in /home/sites/yourarena.co.uk/public_html/members/index.php on line 82, referer:

// Query for finding out if the signed in user is part of any clubs and then display them here.
					$qMyClub = "SELECT clubID, name FROM clubs WHERE memberID = ".$User['memberID']."";
					$rMyClub = mysql_query($qMyClub);
					$NumClubs = mysql_num_rows($rMyClub);
					if ($NumClubs>=1) { 
					 while($Clubs = mysql_fetch_assoc($rMyClub)){
					  echo"<li>My Clubs
                        	<ul>
                            <li><a href=\"members/myclub.php?club='{$Club['clubID']}'\">{$Club['name']}</a></li>
                            </ul>
                        </li>";						 
					}
					else ($NumClubs=0) {
					echo"
					 <li>My Clubs
                        	<ul>
                            <li>None</li>
                            </ul>
                        </li>";	
					}
					 }


 

it means this line

else ($NumClubs==0) {

 

I tried changing it to just one = but nothing

Link to comment
Share on other sites

Perhaps...

 

<?PHP
// Query for finding out if the signed in user is part of any clubs and then display them here.
$member_id = $User['memberID'];
$qMyClub = "SELECT clubID, name FROM clubs WHERE memberID = $member_id'";
$rMyClub = mysql_query($qMyClub);
$NumClubs = mysql_num_rows($rMyClub);
if ($NumClubs>=1) { 
	?>
	My Clubs<br>
	<ul>
	<?PHP
	while($Clubs = mysql_fetch_assoc($rMyClub)){
		?>
		<li><a href="members/myclub.php?club=<?PHP echo $Club['clubID']; ?>"><PHP echo $Club['name']; ?></a></li>
		<?PHP
	}
	<?PHP
	</ul>
	<?PHP
}
}else{
?>
My Clubs<br>
<ul>
<li>None</li>
</ul>
<?PHP
}
?>

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.