Fwd: Newbie Question re substr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, Kim! Still having difficulties though......
On 8 Mar 2005, at 03:29, Kim Madsen wrote:

From: Jackson Linux [mailto:jackson.linux@xxxxxxxxx]
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@xxxxxxx

--
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux