Reply to Re: [PHP] Newbie Question re substr

Your name:

Reply:


Posted by Jackson Linux on 03/08/05 07:05

Zareef,
Almost....
On 7 Mar 2005, at 23:52, Zareef Ahmed wrote:

From: zareef.ahmed@gmail.com
Subject: Re: [PHP] Newbie Question re substr
Date: 7 March 2005 23:52:15 GMT-05:00
To: jackson.linux@gmail.com
Cc: php-general@lists.php.net
Reply-To: zareef.ahmed@gmail.com

On Mon, 7 Mar 2005 22:23:19 -0500, Jackson Linux
<jackson.linux@gmail.com> wrote:
> Hi,
> I'm really new and getting lots of help but need some assistance.
>
> I'm running a script which gets specific articles from a database if
> they're entered in the URL after the ? . For instance if someone asks
> for
>
> www.foo.com/index.htm?a=1234
>
> then the script would look for an database entry with the id of 1234
> and display it in the page.
>
> If there's no number specified (www.foo.com/index.htm) or if the number
> given is to an article which doesn't exist, it gets the titles of all
> the articles available and prints them as links to the proper article
> number.
>
> I'd also like it to grab the first 200 characters of text from the
> $content field of the entry.
>
> With help I have the title link part and I suspect I'm close but I keep
> messing up the syntax
>
> The code is:
>
> <snip>
>
> if (!empty($where)) {
>
> echo "
> <ul>";
> $article = mysql_fetch_assoc($result);
> } else {
> while ($article = mysql_fetch_assoc($result)) {
> $table_of_contents[] = "
> <li><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'

> title='{$article['title']}'>{$article['title']}</a><br />
> $article['content'] = substr($article['content'], 0 200);</li>";

change these two lines to

title='{$article['title']}'>{$article['title']}</a><br />".
substr($article['content'], 0, 200)."</li>";

zareef ahmed




I did that and now it reads this:



if (!empty($where)) {

echo "
 <ul>";
$article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
$table_of_contents[] = "
<li><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
<li><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
title='{$article['title']}'>{$article['title']}</a><br />".
substr($article['content'], 0, 200)."</li>";
}
}

\
Which doesn't kick back errors but also does not pull any
$article['content'] - it leaves a line break but no text is being
inserted from the content row.
?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация