Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Junior Member repp55's Avatar
    Join Date
    Dec 2006
    Posts
    8
    Member #
    14591
    I'm using php 5.2, mysql 5.0.22 and a Windows 2000 server.
    My database is structured like so:

    DB:
    clfile ,
    clfile_name
    clfile_size
    clfile_type
    clfile_title
    description
    date_entered

    cl_association,
    cl_assoc_id
    cl_file_id
    cl_category_id
    approved

    categories
    cl_category_id
    cl_category


    What I want to do is have all of the categories list out and each file list underneath them in a bullet list without having to use a form to select the categories. I have my code ready to where it will display one category and the files that are in that category but I'm not sure how to get all of them to do the same.

    here is my code:

    PHP Code:
    <?php //view_files.php


    $page_title = 'View Files';


    $first = TRUE;
    require_once (
    '../_connect/intranet_connect.php');
    $query ="Select cl_category_id FROM cl_categories";
    $result = mysql_query($query);
    (list (
    $type) = mysql_fetch_array($result, MYSQL_NUM));
    {

    $query = "SELECT cl_category FROM cl_categories WHERE cl_category_id=$type";

    $result= mysql_query($query);
    list (
    $category) = mysql_fetch_array($result, MYSQL_NUM)OR die(mysql_error());

    $first=TRUE;
    $query = "SELECT c.clfile_id, clfile_name, clfile_title, DATE_FORMAT(date_submitted, '%M %e, %Y') as d , description FROM clfile AS c, cl_association AS ca WHERE c.clfile_id = ca.clfile_id AND ca.cl_category_id=$type AND ca.approved = 'Y' ORDER BY date_submitted DESC";

    $result = mysql_query ($query);

    while (
    $row = mysql_fetch_array($result, MYSQL_ASSOC))
    {

    if(
    $first)
    {
    echo
    "<table border=\"0\" width=\"80%\" cellspacing=\"3\" cellpadding=\"3\" align=\"center\">
    <tr>
    <td><strong>$category</strong></td>
    <Td><strong>Date</strong></td>
    </tr>"
    ;
    $first = FALSE;
    }

    echo
    "<tr><ul>
    <td align=\"left\"><li><a href=\"../php/test/download.php?uid={$row['clfile_id']}\">{$row['clfile_title']}</a></td>
    <td><font color=\"red\">*{$row['d']}*</li></td></a>
    </tr>\n"
    ;
    }

    if(
    $first)
    {
    echo
    '<p>There are no files</p>';
    }
    else
    {
    echo
    '</table>';
    }
    }
    mysql_close();

    ?>




    Sorry about the long post. Thank you all for your help!

  2.  

  3. #2
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    I would say change this:

    PHP Code:
    (list ($type) = mysql_fetch_array($resultMYSQL_NUM));

    to this:

    PHP Code:
    while(list ($type) = mysql_fetch_array($resultMYSQL_NUM))

    choosy developers choose gif!
    website | paintings | blog

  4. #3
    Junior Member repp55's Avatar
    Join Date
    Dec 2006
    Posts
    8
    Member #
    14591
    First off thank you for the suggestion, I just tried it and all that came out was still the one category with those files. Is it just impossible to do this without a form select?

  5. #4
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    what are you saying? you don't want to use the SQL SELECT?
    choosy developers choose gif!
    website | paintings | blog

  6. #5
    Junior Member repp55's Avatar
    Join Date
    Dec 2006
    Posts
    8
    Member #
    14591
    Sorry I meant that I dont want to use a form drop down selection to have to pick the category. I want all of the categories and files to just display. Sorry about the confusion.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:01 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com