RE: [PHP] Newbie Question re substr
| From: | Kim Madsen | Date: | Tue, 08 Mar 2005 08:29:43 +0000 |
| Subject: | RE: [PHP] Newbie Question re substr | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-210207@lists.php.net to get a copy of this message | ||
From: 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)) {
// 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 :-)
--
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