Jump to content

[SOLVED] is this possible


dezkit

Recommended Posts

if there is a space in $name, so there is $nickname

 

$name = "justin beos";

$nickname = "powda";

 

<a href="index.php?p=profile&pid=<?=$r['id']?>">
<?=$r['name']?> <?=$r['nickname']?>
</a>

 

output has to be

 

Justin "Powda" Beos

 

not

 

Justin Beos Powda

Link to comment
Share on other sites

Ok. Another time, please don't modify the post after people have responded.

 

You can do this (not tested):

 

$names = array_map('ucwords', explode(' ', $r['name']));
$name = "{$names[0]} \"" . ucwords($r['nickname']) . "\" {$names[1]}";

Link to comment
Share on other sites

this is my whole code

 


<h2 class="main"><span>Roster</span></h2>
<div class="cbox roster">
<div style="text-align: center;">
<?
$q = mysql_query("SELECT * FROM `roster` ORDER BY `team` DESC");
$members = mysql_num_rows($q);

if($members) {
	?>
	<table cellspacing="0" class="full">
	<?
	$i = 0;
	$team = "";
	while($r = mysql_fetch_array($q)) {
		$i += 1;
			if(file_exists("images/roster/".$r['id'].$r['filetype'])) {
				$pic = "images/roster/".$r['id'].$r['filetype'];
			} else {
				$pic = "images/roster/blankpic.jpg";
			}
		if($team != $r['team']) {
		$team = $r['team'];
		?>
		<tr>
			<td colspan="3" class="teamdivider"><?=$team?></td>
		</tr>
		<? } ?>
		<tr class="row<?=($i&1)?>">
			<td><img src="<?=$pic?>" width="50" alt="" /></td>
			<td style="text-align: left;">








<a href="index.php?p=profile&pid=<?=$r['id']?>">
<?=$r['name']?> "<?=$r['nickname']?>"
</a>






</td>


		</tr>
	<?
	}
	echo "</table>";
} else {
	echo "<p>We have no players on the roster yet!</p>";
}
?>
</div>
</div>

Link to comment
Share on other sites

I just tried...

 

<?php
$r['name'] = "justin beos";
$r['nickname'] = "powda";

$names = array_map('ucwords', explode(' ', $r['name']));
$name = "{$names[0]} \"" . ucwords($r['nickname']) . "\" {$names[1]}";

echo $name;
?>

 

outputs:

 

Justin "Powda" Beos

 

Is that not what you wanted? In what way doesn't it work?

Link to comment
Share on other sites

<h2 class="main"><span>Roster</span></h2>
<div class="cbox roster">
<div style="text-align: center;">
<?
$q = mysql_query("SELECT * FROM `roster` ORDER BY `team` DESC");
$members = mysql_num_rows($q);

if($members) {
	?>
	<table cellspacing="0" class="full">
	<?
	$i = 0;
	$team = "";
	while($r = mysql_fetch_array($q)) {
		$names = array_map('ucwords', explode(' ', $r['name']));
		$name = "{$names[0]} \"" . ucwords($r['nickname']) . "\" {$names[1]}";
		$i += 1;
			if(file_exists("images/roster/".$r['id'].$r['filetype'])) {
				$pic = "images/roster/".$r['id'].$r['filetype'];
			} else {
				$pic = "images/roster/blankpic.jpg";
			}
		if($team != $r['team']) {
		$team = $r['team'];
		?>
		<tr>
			<td colspan="3" class="teamdivider"><?=$team?></td>
		</tr>
		<? } ?>
		<tr class="row<?=($i&1)?>">
			<td><img src="<?=$pic?>" width="50" alt="" /></td>
			<td style="text-align: left;">








<a href="index.php?p=profile&pid=<?=$r['id']?>">
<?= $name ?>
</a>






</td>


		</tr>
	<?
	}
	echo "</table>";
} else {
	echo "<p>We have no players on the roster yet!</p>";
}
?>
</div>
</div>

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.