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
    Regular Coder
    Join Date
    Aug 2002
    Posts
    264
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Coding help... With Categories....

    I need the category ID where it says category ID here, I tried putting some codes but it didnt work... Please help thanks




    PHP Code:
    <div style="background-color:#7E7E7E; border: 1px solid black; padding: 1px;">
    <div style="border: 1px solid black; height: 15px; background-image: url(images/menubg.gif); 

    text-align: left;">
    <img src="images/headers/[SIZE=4]CATEGORY ID HERE!!!!!![/SIZE] .gif" width="140" height="15" 

    alt=""></div></div>
    <img src="images/spacer.gif" width="3" height="3" alt=""><br>
    <div style="background-color:#7E7E7E; border: 1px solid black; padding: 1px;">
    <div style="border: 1px solid black; height: 17; background-color: #151515; text-align: center; 

    padding: 10px;">

    <div style="background-color:#7E7E7E; border: 1px solid black; padding: 1px;"><table 

    cellspacing="0" cellpadding="5" bgcolor="#1f1f1f" border="1" bordercolor="#000000" 

    style="border-width:0; border-collapse: collapse; width:100%;">
    <?php
    /*
      paFileDB 3.1
      ©2001/2002 PHP Arena
      Written by Todd
      [email]todd@phparena.net[/email]
      [url]http://www.phparena.net[/url]
      Keep all copyright links on the script visible
      Please read the license included with this script for more information.
    */
    $category $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_cat WHERE cat_id = '$id'"1);
    if (
    $category[5] == 0) { $locbar "<a href=\"pafiledb.php\" class=\"small\">$config[1]</a> :: 

    $category[1]"
    ; }
    if (
    $category[5] > 0) {
        
    $parent $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_cat WHERE cat_id = 

    '$category[5]'"
    1);
        
    $locbar "<a href=\"pafiledb.php\" class=\"small\">$config[1]</a> :: <a 

    href=\"pafiledb.php?action=category&id=$parent[0]\" class=\"small\">$parent[1]</a> :: 

    $category[1]"
    ;
    }
    if (
    $logged == 1) {
        
    adlocbar($locbar$user,$str);
        
    adminlinks_viewcat($str,$id);
    } else {
        
    locbar($locbar);
    }
    $result $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_cat WHERE cat_parent = '$id' ORDER 

    BY cat_id"
    0);
    $n mysql_num_rows($result);
    if (
    $n 0) {
        echo(
    "<table cellspacing=\"0\" cellpadding=\"5\" bgcolor=\"#1f1f1f\" border=\"1\" 

    bordercolor=\"#000000\" style=\"border-width:0; border-collapse: collapse; width:100%;\">
            <tr><td width=\"90%\" class=\"headercell\"><center><b>$str[category]</b></center></td><td 

    width=\"10%\" class=\"headercell\"><center><b>$str[files]</b></center></td></tr>"
    );
        
    #$result = $pafiledb_sql->query($db, "SELECT * FROM $db[prefix]_cat WHERE cat_parent = 

    '$id' ORDER BY cat_id", 0);
        while ($sub = mysql_fetch_object($result)) {
            $filesincat = $pafiledb_sql->query($db, "
    SELECT FROM $db[prefix]_files WHERE 

    file_catid 
    '$sub->cat_id'", 2);
            echo "
    <tr><td width="90%\" class=\"datacell\"><a 

    href=\"pafiledb.php?action=category&id=$sub->cat_id\">$sub->cat_name</a><br><a 

    class=\"smalltext\">&raquo; $sub->cat_desc &laquo;</a></td><td width=\"10%\" 

    class=\"datacell\"><center>$filesincat</center></td></tr>"
    ;
        }
        echo
    "</table><p>";
    }
    $result $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_files WHERE file_catid = '$id' AND 

    file_pin = '1' ORDER BY file_id"
    0);
    /*PINNED*/
    while ($pin mysql_fetch_object($result)) {
        
    $date date("n/j/y"$pin->file_time);
        
    $ntv $pin->file_totalvotes 1;
        if (
    $pin->file_rating == or $ntv == 0) { $rating 0; } else {$rating 

    round($pin->file_rating/$ntv2); }
        
    $filelist .= "<tr><td width=\"5%\" align=\"center\" class=\"datacell\"><img 

    src=\"styles/$config[11]/images/pin.gif\"></td><td width=\"65%\" class=\"datacell\"><a 

    href=\"pafiledb.php?action=file&id=$pin->file_id\" class=\"pin\">$pin->file_name</a><br><a 

    class=\"smalltext\">&raquo; $pin->file_desc &laquo;</a></td><td width=\"10%\" 

    class=\"datacell\"><center>$date</center></td><td width=\"10%\" 

    class=\"datacell\"><center>$rating/10</center></td><td width=\"10%\" 

    class=\"datacell\"><center>$pin->file_dls</center></td></tr>"
    ;
    }
    $start trim($start);
    if (empty(
    $start)) {
        
    $start 0;
    }
    if (empty(
    $sortby)) { $sortby "name"; }
    if (
    $sortby == "name") {
        
    $result $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_files WHERE file_pin = '0' 

    AND file_catid = '$id' ORDER BY file_name ASC LIMIT $start,20"
    0);
    }
    if (
    $sortby == "date") {
        
    $result $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_files WHERE file_pin = '0' 

    AND file_catid = '$id' ORDER BY file_time DESC LIMIT $start,20"
    0);
    }
    if (
    $sortby == "downloads") {
        
    $result $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_files WHERE file_pin = '0' 

    AND file_catid = '$id' ORDER BY file_dls DESC LIMIT $start,20"
    0);
    }
    if (
    $sortby == "rating") {
        
    $result $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_files WHERE file_pin = '0' 

    AND file_catid = '$id' ORDER BY (file_rating/file_totalvotes) DESC LIMIT $start,20"
    0);
    }
    $filesincat $pafiledb_sql->query($db"SELECT * FROM $db[prefix]_files WHERE file_catid = '$id' 

    AND file_pin = '0'"
    2);
    if (
    $filesincat == 0) {
        
    $filesincat 1;
    }
    /*NOT PINNED*/
    while ($file mysql_fetch_object($result)) {
        
    $date date("n/j/y"$file->file_time);
        
    $ntv $file->file_totalvotes 1;
        if (
    $file->file_rating == or $ntv == 0) { $rating 0; } else {$rating 

    round($file->file_rating/$ntv2); }
        if (
    $file->file_posticon == "none" or $file->file_posticon == "none.gif") {
            
    $posticon "&nbsp;";
        } else {
            
    $posticon "<img src=\"images/posticons/$file->file_posticon\">";
        }
        
    $filelist .= "<tr><td width=\"5%\" align=\"center\" class=\"datacell\">$posticon</td><td 

    width=\"65%\" class=\"datacell\"><a 

    href=\"pafiledb.php?action=file&id=$file->file_id\">$file->file_name</a><br><a 

    class=\"smalltext\">&raquo; $file->file_desc &laquo;</a></td><td width=\"10%\" 

    class=\"datacell\"><center>$date</center></td><td width=\"10%\" 

    class=\"datacell\"><center>$rating/10</center></td><td width=\"10%\" 

    class=\"datacell\"><center>$file->file_dls</center></td></tr>"
    ;
    }
    $numpages ceil($filesincat 20);
    if (
    $start 20 $filesincat) {
        
    $newstart $start 20;
        
    $next "<a 

    href=\"pafiledb.php?action=category&id=$id&start=$newstart&sortby=$sortby\">$str[next] 

    &raquo;</a>"
    ;
    }
    if (
    $start 20 >= 0) {
        
    $newstart $start 20;
        
    $prev "<a 

    href=\"pafiledb.php?action=category&id=$id&start=$newstart&sortby=$sortby\">&laquo; 

    $str[prev]</a>"
    ;
    }
    for (
    $i 0$i $numpages$i++) {
        
    $newstart 20*$i;
        
    $pagenum $i 1;
        if (
    $newstart == $start) {
            
    $pages .= "$pagenum ";
        } else {
            
    $pages .= "<a 

    href=\"pafiledb.php?action=category&id=$id&start=$newstart&sortby=$sortby\">$pagenum</a> "
    ;
        }
    }
    $filelist trim($filelist);
    if (!empty(
    $filelist)) {
        
    ?>
        <table width="100%" border="1" cellpadding="2" cellspacing="0" class="headertable" 

    bordercolor="#000000">
        <tr><td width="5%" class="headercell"></td><td width="65%" 

    class="headercell"><center><b><?php echo $str[file]; ?></b></center></td><td width="10%" 

    class="headercell"><center><b><?php echo $str[date]; ?></b></center></td><td width="10%" 

    class="headercell"><center><b><?php echo $str[rating]; ?></b></center></td><td width="10%" 

    class="headercell"><center><b><?php echo $str[dls]; ?></b></center></td></tr>
        <?php
        
    echo $filelist;
        
    ?>
        <form action="index.php?page=downloads/pafiledb" method="post"><input type="hidden" 

    name="action" value="category"><input type="hidden" name="id" value="<?php echo $id?>">
        <input type="hidden" name="start" value="<?php echo $start?>">
        <tr><td width="100%" colspan="5" align="center" valign="middle" class="headercell"><?php 

    echo $str[sortby]; ?>
        <select name="sortby" style="vertical-align:middle">
        <option value="name"><?php echo $str[name]; ?></option>
        <option value="date"><?php echo $str[date]; ?></option>
        <option value="rating"><?php echo $str[rating]; ?></option>
        <option value="downloads"><?php echo $str[dls]; ?></option>
        </select><input type="submit" value="<?php echo $str[sort]; ?>

    style="vertical-align:middle"></center></td></tr></form>
        </table>
        <table width="100%" border="0" cellpadding="2" cellspacing="0" class="headertable" 

    bordercolor="#000000">
        <tr><td width="33%" class="datacell" align="left"><?php echo $prev?></td>
        <td width="33%" class="datacell" align="center"><?php echo "$str[pagenums]: $pages"

    ?></td>
        <td width="34%" class="datacell" align="right"><?php echo $next?></td></tr>
        </table>
        <?php 
    } else {
        
    ?><table width="100%" border="1" cellpadding="2" cellspacing="0" class="headertable" 

    bordercolor="#000000">
        <tr><td width="100%" colspan="2" class="headercell"><center><b>No Files 

    Found</b></center></td></tr>
        <tr><td width="5%" class="datacell" align="center" valign="middle"><img src="styles/<?php 

    echo $config[11]; ?>/images/info.gif" border="0"></td>
        <td width="95%" class="datacell">No files are in this category.</td></tr></table><?php    
    }
    if (
    $logged == 1) { echo "</td></tr></table>"; } ?>
    Please visit http://www.thickandthinpizza.com and tell me what you think.

  • #2
    New Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    replace CATEGORY ID HERE!!!!!!

    with (for the category name)
    PHP Code:
    <?=$category[1];?>
    with (for the category ID)
    PHP Code:
    <?=$category[0];?>
    that should be it?

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    @ funkel

    To do what you're wanting thicknthin, you need to execute the php before where you want the "category id" to be shown. I don't have time to sort it out for you, and it does look like alot of code to mess about with to do something that should be so simple. Maybe someone who's got time will sort it for you

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    looking at the code, <?=$id?> should give you the category id
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)


  •  

    Posting Permissions

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