Jump to content


Photo

Help with <LI> hyperlink


  • Please log in to reply
2 replies to this topic

#1 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 14 August 2006 - 12:18 PM

Can someone please help get this linking right?
I have the 5 latest news articles listed so the last entry is the first listed and is displayed on the first page.
I need to change the link so instead of using the article id it uses the the list item number (1-5) so if the user clicks on the 1st article it goes to page 1 etc

Is it possible to use a for loop add increment the link page by 1 each time and if so how?

If you check out my site you'll see what I mean under latest news

http://www.project-sw.co.uk/jack

include_once("includes/connection.php");
$q = mysql_query("SELECT id, title FROM news ORDER BY id DESC LIMIT 5"); 
echo "<OL id=\"blah\">"; 
while($articles = mysql_fetch_object($q)) { 
    echo "<LI><a class=\"one\" href=\"http://www.project-sw.co.uk/jack/index.php?page=news&limit=1&pagenum=".$articles->id."\">".$articles->title."</a></LI>"; 
}

If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 August 2006 - 12:24 PM

It will be much more friendly for your users to click a string of words than to click a single digit.  The numbers in an ordered list are not accessible in the way you want.  If you really want to have numbers, then drop the ordered list concept and simply modify your output code to echo a link to a counter that starts at 1 and increments in your output loop.
Legend has it that reading the manual never killed anyone.
My site

#3 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 14 August 2006 - 12:59 PM

I've done it.

You gave me an idea about using a counter.  I just changed the code to this

$counter = 1;
$q = mysql_query("SELECT id, title FROM news ORDER BY id DESC LIMIT 5"); 
echo "<OL id=\"blah\">"; 
while($articles = mysql_fetch_object($q)) { 
    echo "<LI><a class=\"one\" href=\"http://www.project-sw.co.uk/jack/index.php?page=news&limit=1&pagenum=".$counter."\">".$articles->title."</a></LI>"; 
$counter = $counter + 1;
}
echo"</OL>";
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users