You are here: Fwd: [PHP] Newbie Question re substr « PHP « IT news, forums, messages
Fwd: [PHP] Newbie Question re substr

Posted by Jackson Linux on 03/08/05 14:12

Thanks, Kim! Still having difficulties though......
On 8 Mar 2005, at 03:29, Kim Madsen wrote:
>
>> 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 :-)
>>
>
> It's really sensible and logical what you did. I really appreciate it.
>
> 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 get
>
> Parse 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
>>
>>
>>
> ---------
>
>
---------
Nick Selby
Flyguides, Inc.
347 675 8295
http://www.flyguides.com/press/selby.htm

 

Navigation:

[Reply to this 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

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