SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Dec 23, 2000, 19:41 #1
- Join Date
- Dec 2000
- Location
- USA
- Posts
- 39
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:$result = mysql_query("SELECT * FROM Links ORDER BY stamp DESC"); if (!$result){ $body = "mysql_error()"; $title = "Error!"; } $i = 0; while ($row = mysql_fetch_array($result)) { $date = $row["date"]; $url = $row["url"]; $title = $row["title"]; $descrip = $row["descrip"]; $body = "<br><br><div align=center><center>" . "<table border=0 width=600 cellpadding=0 cellspacing=0><tr>" . "<td width=600 bgcolor=#000000></td></tr><tr><td width=600 bgcolor=#FCC403><table border=0 width=100% cellspacing=1><tr>" . "<td width=33%><strong><small><a href=$url>$title</a></small></strong></td>" . "<td width=33%><p align=right><small><small>Added on $date</small></small></td>" . "<td width=34%><p align=right><small><small><a href=addlink.php>Add your link</a></small></small></td>" . "</tr></table></td></tr><tr><td width=100% bgcolor=#000000></td></tr><tr>" . "<td width=100%><small>$descrip</small></td>" . "</tr></table></center></div>"; $title = "Links"; }
Thanks, MethoD
-
Dec 23, 2000, 20:14 #2
Hi
$result = mysql_query("SELECT * FROM Links ORDER BY stamp DESC");
Modify the above code thusly and it should work.
$result = mysql_query("SELECT * FROM Links ORDER BY stamp DESC LIMIT 50");
Have not tried it but that is the proper implementation of the Limit
peace
Ed Shuck
www.noevalley.com
-
Dec 23, 2000, 20:26 #3
- Join Date
- May 2000
- Location
- Canada
- Posts
- 533
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
just another thing I noticed:
you might want to change
if (!$result){
to
if (mysql_num_rows($result) == 0){
-------------------
SitePoint Community Advisor
myPHPhost.com: when you want something MORE in a host
-
Dec 23, 2000, 20:49 #4
- Join Date
- Dec 2000
- Location
- USA
- Posts
- 39
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok thanks
one more question
Code:while ($row = mysql_fetch_array($result)) { $date = $row["date"]; $url = $row["url"]; $title = $row["title"]; $descrip = $row["descrip"]; $format = str_replace("<InsertTitle>", "$title", $format); $format = str_replace("<InsertDate>", "$date", $format); $format = str_replace("<InsertUrl>", "$url", $format); $format = str_replace("<InsertDescription>", "$descrip", $format); $body = $format; $title = "Links"; }
Hmmmmmmm. I'm stumped. I'm using a custom made template based ffa script and it stores everything it needs in the $body variable which is displayed later on. How can I get each generated link format ($format) into the $body var so I can display all of the links?
Maybe an array?
I'm not sure.
-
Dec 24, 2000, 04:34 #5
- Join Date
- Oct 2000
- Posts
- 89
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
$body .= $format;
Great Dane
Gokhan ARLI
-
Dec 24, 2000, 11:39 #6
- Join Date
- Dec 2000
- Location
- USA
- Posts
- 39
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmmm... That's not working either. It works just the same as doing
$body = $body .
$fearures
It shows the latest link for however many entries there are in the database.
-
Dec 24, 2000, 12:06 #7
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It seems that $format never gets reset to it s original value so after the first loop the str_replace never actually replaces anything I think you will need to declare $format in its original state at the beginning of the loop so that each time it goes through it has the proper $format string to work with.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Dec 24, 2000, 13:31 #8
- Join Date
- Dec 2000
- Location
- USA
- Posts
- 39
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Alright
Thanks a lot!!!
Bookmarks