dezkit Posted June 2, 2008 Share Posted June 2, 2008 is it possible so that if Team2 has a name of more than 4, so that it shows three dots "..." <h2 class="matches"><span>Matches</span></h2> <div class="cbox"> <div class="matches"> <? $q = mysql_query("SELECT * FROM `matches` ORDER BY id DESC LIMIT 0,5"); $matches = mysql_num_rows($q); if($matches > 0) { ?> <table cellspacing="0" style="font-size: 10px;"> <? $i = 0; while($r = mysql_fetch_array($q)) { $i += 1; $winner = split("-",$r['score']); if($winner[0] > $winner[1]) { $status = "<td class=\"win\">Win</td>"; } else if($winner[0] < $winner[1]) { $status = "<td class=\"loss\">Loss</td>"; } else { $status = "<td class=\"tie\">Tie</td>"; } ?> <tr class="row<?=($i&1)?>"> <td><font style="font-size:9px; color: #888888;">vs</font> <?=$r['team2']?></td> <td class="score"><?=$r['score']?></td> <?=$status?> </tr> <? } ?></table><? } else { echo "<p>We haven't played any matches yet!</p>"; } ?> <p><a href="index.php?p=matches">View all matches</a></p> </div> </div> Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/ Share on other sites More sharing options...
DarkWater Posted June 2, 2008 Share Posted June 2, 2008 if (strlen($name) > 4) { $name .= "..."; } Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555909 Share on other sites More sharing options...
whizard Posted June 2, 2008 Share Posted June 2, 2008 you mean if(strlen($Team2) > 4) { print "..."; } oops... got beat Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555910 Share on other sites More sharing options...
dezkit Posted June 2, 2008 Author Share Posted June 2, 2008 thanks for the code, but where do i put? Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555911 Share on other sites More sharing options...
dezkit Posted June 2, 2008 Author Share Posted June 2, 2008 oops i worded it wrong, i meant so that if team2 has more than 4 characters, display the first 4 characters and then display "..." Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555913 Share on other sites More sharing options...
DarkWater Posted June 2, 2008 Share Posted June 2, 2008 @whizard: Wasn't paying attention to the var name, lol. @dezkit: if (strlen($Team2) > 4) { $Team2 = substr($Team2, 0, 4) . "..."; } Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555914 Share on other sites More sharing options...
whizard Posted June 2, 2008 Share Posted June 2, 2008 wow DarkMatter... you're fast! It took me like 30seconds to read and respond but when I hit submit, it said someone had already posted! lol Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555915 Share on other sites More sharing options...
discomatt Posted June 2, 2008 Share Posted June 2, 2008 One line... echo ( strlen( $r['team2'] ) > 4 ? substr( $r['team2'], 0, 4 ).'...' : $r['team2'] ); Replace <?=$r['team2']?> With <?php echo ( strlen( $r['team2'] ) > 4 ? substr( $r['team2'], 0, 4 ).'...' : $r['team2'] ); ?> Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555916 Share on other sites More sharing options...
dezkit Posted June 2, 2008 Author Share Posted June 2, 2008 haha, thanks DarkWater and discomatt!!! P.S. @whizard.... its DarkWater not DarkMatter Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555918 Share on other sites More sharing options...
DarkWater Posted June 2, 2008 Share Posted June 2, 2008 @whizard: I type quickly. =P @dezkit: Use discomatt's (same as mine, just he showed you where to put it) Also @dezkit: Don't use short tags (<?= ). Use regular php tags, it's always better. Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555919 Share on other sites More sharing options...
dezkit Posted June 2, 2008 Author Share Posted June 2, 2008 kk, thanks bro. <3 topic solved Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555922 Share on other sites More sharing options...
discomatt Posted June 2, 2008 Share Posted June 2, 2008 Just to elaborate... using full tags isn't necessarily 'better.' Full tags are more compatible... as some server have short tags turned off. If you want to make sure you script will work on ANY php build you execute it on, always use full tags (<?php #code# ?> ) If you only plan on executing the script on YOUR server, then short tags are fine and dandy and will save you a bit of time and disk space Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555926 Share on other sites More sharing options...
DarkWater Posted June 2, 2008 Share Posted June 2, 2008 If he is going to worry himself to sleep over 7 bytes (no last 'p', no space, no echo, and no space), then he needs to reconsider his priorities. =P And yeah, don't use short tags if you want it to always be compatible. Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555932 Share on other sites More sharing options...
dezkit Posted June 2, 2008 Author Share Posted June 2, 2008 i got Unlimited disk space and Unlimited data transfer on my webhost so no worries!! Link to comment https://forums.phpfreaks.com/topic/108436-solved-php-limit/#findComment-555938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.