SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist Deano's Avatar
    Join Date
    Mar 2003
    Location
    Derbyshire, UK
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error when making a link

    Hi all,

    I'm building a link index system for my community, things are going well and starting to take shape slowly now.

    I've just reworked the layout of the main category listing, and now working on a link for the specific category.
    However everytime I try to create the link it doesnt seem to work.

    Below is the layout of what Im trying to achieve :

    PHP Code:
    <?php
    $columns 
    2;

    include(
    "conf.php" ); 

    $connection mysql_connect($host$user$pass) or die ("Unable to connect!" ); 

    mysql_select_db($db) or die ("Unable to select database!" ); 

    //change the query to get another field from the database
    $query "SELECT ID,name, description FROM link_categories";
    //displays the number of categories in the data base !
    $rs mysql_fetch_rowmysql_query("SELECT COUNT(*) FROM link_categories" ) );  
            echo(
    "$rs[0] Categories");

    $query 
    SELECT 
    cat.ID, cat.description, cat.name, count(*) as total 
    FROM 
    link_categories cat, link 
    WHERE 
    cat.ID = cid 
    GROUP BY 
    cat.ID, cat.name , cat.description
    '


    //count number of links
    $rs mysql_fetch_rowmysql_query("SELECT COUNT(*) FROM link" ) );  
     
    //displays the number of categories items in the data base !
            
    echo(" and $rs[0] links<p>") ;
    $result mysql_query($query);

    $num_rows mysql_num_rows($result);


    $rows ceil($num_rows $columns);

    while(
    $row mysql_fetch_array($result)) {
        
    $data[] = $row['name'];
        
        
    //store the other field into an array
        
    $data2[] = $row['total'];
              
        
    //store the other field into an array
        
    $data3[] = $row['description'];
        
        
    //store the other field into an array
        
    $data4[] = $row['ID'];
           
    }
    echo 
    "<TABLE border=\"1\" bordercolor=\"white\" cellspacing=\"0\" cellpadding=\"5\">\n";

    for(
    $i 0$i $rows$i++) {

        echo 
    "<TR>\n";
        
        for(
    $j 0$j $columns$j++) {
            if(isset(
    $data[$i + ($j $rows)])) {
                echo 
    "<TD bgcolor=\"#EEEEEE\" valign=\"abs_middle\"><img src=\"images/cat_image.gif\"> ID#"$data4[$i + ($j $rows)] . " " $data[$i + ($j $rows)] . "</a></b> (" $data2[$i + ($j $rows)] . ")<br>" $data3[$i + ($j $rows)] . "</TD>\n";
               
        
            }
        }
        echo 
    "</TR>\n</div>";
    }
    echo 
    "</TABLE>\n";

    ?>
    The area I'm trying to create a link for is this line here :
    PHP Code:
    echo "<TD bgcolor=\"#EEEEEE\" valign=\"abs_middle\"><img src=\"images/cat_image.gif\"> "$data4[$i + ($j $rows)] . " " $data[$i + ($j $rows)] . "</b> (" $data2[$i + ($j $rows)] . ")<br>" $data3[$i + ($j $rows)] . "</TD>\n"
    I'm trying to pull the data via its ID number which is data4 but use the data for the link, this is what Im trying to achieve below :

    PHP Code:
    <a href="display_a_cat.php?id='\". $data4[$i + ($j * $rows)] . " " . $data[$i + ($j * $rows)] . "</a
    Any help will be greatly apprecieated.

    Best Regards
    Deano

  2. #2
    SitePoint Evangelist Deano's Avatar
    Join Date
    Mar 2003
    Location
    Derbyshire, UK
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone to the rescue ?


Bookmarks

Posting Permissions

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