Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    87
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Why is this code not displaying links

    The code below is not displaying titles in a database table column on a webpage, leave alone showthe hyperlinks. What could be problem?
    Code:
    $query = mysql_query("SELECT Title FROM entries LIMIT $startResults, $resultsPerPage");
    
    while ($output = mysql_fetch_assoc($query))
            $Index=$output['Index']; 
    	echo '<a href="selected_post.php?Index='.$Index.'">' .$output['Title'].'</a>';

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    709
    Thanks
    20
    Thanked 84 Times in 84 Posts
    PHP Code:

    $query 
    mysql_query("SELECT Title, Index FROM entries LIMIT $startResults, $resultsPerPage");

    while (
    $output mysql_fetch_array($query)){
        echo 
    '<a href="selected_post.php?Index='.$output['Index'].'">' .$output['Title'].'</a>';

    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    87
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Arcticwarrio, I've implemented your coding and I've gotten another error which reads:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a3763404/public_html/archives.php on line 89
    Line 89 is
    Code:
    while ($output = mysql_fetch_array($query)){

  • #4
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    709
    Thanks
    20
    Thanked 84 Times in 84 Posts
    try
    PHP Code:

    $query 
    mysql_query("SELECT Title, Index FROM entries LIMIT $startResults, $resultsPerPage") or die ('Error: '.mysql_error ());

    while (
    $output mysql_fetch_array($query)){
        echo 
    '<a href="selected_post.php?Index='.$output['Index'].'">' .$output['Title'].'</a>';

    or

    PHP Code:

    $query 
    mysql_query("SELECT * FROM entries") or die ('Error: '.mysql_error ());

    while (
    $output mysql_fetch_array($query)){
        echo 
    '<a href="selected_post.php?Index='.$output['Index'].'">' .$output['Title'].'</a>';

    either of those output anything?
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •