lorddemos90 Posted May 9, 2007 Share Posted May 9, 2007 does anybody know if there is a way to display only certain text contained in a mysql cell. For example, could I only display text located between certain characters such as * or something like that? But leave the rest of the text in the cell undisplayed on the webpage. Quote Link to comment https://forums.phpfreaks.com/topic/50713-only-display-specific-text-in-a-mysql-field/ Share on other sites More sharing options...
Barand Posted May 9, 2007 Share Posted May 9, 2007 It would be easier to use php code to extract the text required prior to displaying than it would be using MySQL functions Quote Link to comment https://forums.phpfreaks.com/topic/50713-only-display-specific-text-in-a-mysql-field/#findComment-249327 Share on other sites More sharing options...
lorddemos90 Posted May 14, 2007 Author Share Posted May 14, 2007 And how would that be done? Quote Link to comment https://forums.phpfreaks.com/topic/50713-only-display-specific-text-in-a-mysql-field/#findComment-252699 Share on other sites More sharing options...
Dragen Posted May 14, 2007 Share Posted May 14, 2007 use mysql to get the data then explode it. <?php $sql = "SELECT * FROM tablename WHERE id = '$id' ORDER BY id"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $result = explode('*', $row['cellname']); echo $result[1]; } } else { echo "Sorry, but no results were found found\n"; } } else { echo mysql_error() . "\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50713-only-display-specific-text-in-a-mysql-field/#findComment-252702 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.