Fwd: [PHP] Newbie Question re substr
| From: | Jackson Linux | Date: | Tue, 08 Mar 2005 12:12:13 +0000 |
| Subject: | Fwd: [PHP] Newbie Question re substr | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-210214@lists.php.net to get a copy of this message | ||
Thanks, Kim! Still having difficulties though......
On 8 Mar 2005, at 03:29, Kim Madsen wrote:
Nick Selby Flyguides, Inc. 347 675 8295 http://www.flyguides.com/press/selby.htmFrom: Jackson Linux [mailto:jackson.linux@gmail.com] Sent: 8. marts 2005 04:23 First of all, echo the output to see if You get, what Tou expect in a debug situation: if (!empty($where)) { echo " <ul>"; $article = mysql_fetch_assoc($result); } else { while ($article = mysql_fetch_assoc($result)) {It's really sensible and logical what you did. I really appreciate it.// humanize data $article_id = $article['article_id']; $title = $article['title']; $content = substr($article['content'], 0 200); // get first 200 chars // print and see if we get, what we expect Print "id=$article_id<br>title=$title<br>content=$content<p>"; // now make the real stuff print "<li><a href='{" . $_SERVER['PHP_SELF'] . "}?a={$article_id}'}&title='{$title}'>{$article['title']}</a><br />\n$content</li>";} } echo " </ul>"; I´ve put the "&" in front of title since the link otherwise would be <a href="a=1234title=sometext">, which is not what You want I guess. And I substituted the $article['content'] = substr($article['content'], 0 200);</li>"; } } with $content</li>"; since I believe You want to print the content and not just assign it? Otherwise the <br /> makes no sense :-)Can anyone help ?I hop that did the trick for You :-)1. $content = substr($article['content'], 0 200); // get first 200 chars is choking, and I've looked in docs and can't understand why. I getParse error: parse error, unexpected T_LNUMBER in /usr/www/users/domain/dynamic/templates/substr.htm on line 57 2. This correction:I´ve put the "&" in front of title since the link otherwise would be <a href="a=1234title=sometext">, which is not what You want I guess.Wow. Actually I wanted it to make <a href='a=1234' title='sometext'> - does this: print "<li><a href='{" . $_SERVER['PHP_SELF'] . "}?a={$article_id}'}' title='{$title}'>{$article['title']}</a><br />\n$content</li>"; do that? (I ask because I can;t make any of it work?!) Thanks so much for your help.-- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler Naverland 31 DK-2600 Glostrup www.comx.dk Telefon: +45 70 25 74 74 Telefax: +45 70 25 73 74 E-mail: km@comx.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php--------- ---------