justAnoob Posted April 28, 2009 Share Posted April 28, 2009 i have info stored in a mysql table that is displayed into a table on my site. one of the rows in the table is a description that could be a whole lot of text. The code below displays the data from the mysql table but what I'm looking to do is only display about 50 or so characters, and then have a text link after the text saying "Read More". Where should I start going about this??? Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/ Share on other sites More sharing options...
ignace Posted April 28, 2009 Share Posted April 28, 2009 http://www.php.net; http://be.php.net/substr more precisely Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821349 Share on other sites More sharing options...
Mchl Posted April 28, 2009 Share Posted April 28, 2009 substr (or MySQL's function of the same name) Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821350 Share on other sites More sharing options...
Maq Posted April 28, 2009 Share Posted April 28, 2009 The code below displays the data Where? Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821353 Share on other sites More sharing options...
revraz Posted April 28, 2009 Share Posted April 28, 2009 He wrote it in lemon juice, so you can't see it unless you know how to decode it. The code below displays the data Where? Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821356 Share on other sites More sharing options...
justAnoob Posted April 28, 2009 Author Share Posted April 28, 2009 sorry, ,,, here is the code i have so far. <?php $uid = $_GET['user_id']; $sql = mysql_query("SELECT imgpath, item_name, description, in_return, user_id FROM $table5 ORDER BY id DESC LIMIT 0, 4"); echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>"; echo "<table border=1> <tr> <td><H3>Image </h3></td> <td><H3>Item Name</H3></td> <td><H3>Description</H3></td><td><H3>Seeking</H3></td></tr>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</td><td align='center'>"; echo $row['item_name']; echo "</td><td align='center'>"; echo $row['description']; echo "</td><td align='center'>"; echo $row['in_return']; echo "</td></tr>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821358 Share on other sites More sharing options...
redarrow Posted April 28, 2009 Share Posted April 28, 2009 Maq, he thort we all got Cristal balls, my ball broke lol. echo "".substr($row['description'],0,50),""; example. <?php $row['description']="i love php, but i find it very hard, but i like the check, at the end of the week!"; echo "".substr($row['description'],0,50),""; ?> Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821360 Share on other sites More sharing options...
justAnoob Posted April 28, 2009 Author Share Posted April 28, 2009 then i would just add the href at the end of that correct???,,, for the Read More link. Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821364 Share on other sites More sharing options...
Maq Posted April 28, 2009 Share Posted April 28, 2009 then i would just add the href at the end of that correct???,,, for the Read More link. Yes, but we don't know how you link the articles/items, w/e it is, so it's impossible to tell you what the URL should look like. Quote Link to comment https://forums.phpfreaks.com/topic/156019-solved-viewing-only-a-certain-amount-of-characters-from-a-mysql-table/#findComment-821399 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.