Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7183805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:04:15+00:00 2026-05-28T18:04:15+00:00

I have limited knowledge of php and mysql, I am trying to learn it

  • 0

I have limited knowledge of php and mysql, I am trying to learn it as I go while creating a very simple CMS from scratch to combine with my PHPBB forum.

The CMS is functional, yet I can only create 1 level of categories. I am failing on having multiple levels of categories, any help would be appreciated.

I have the following columns in categories – cID, Title, Description, Level, Depending. Depending needs to include cID value of the father-category, Level should be +1 to the level value of the father-category.

This is what I have so far with no luck-
The function:

function  addCat($cName, $cDesc, $property) {
$property = "$cLevel, $cDepend";
$query = mysql_query("INSERT INTO categories VALUES(null,'$cName','$cDesc', '$cLevel', '$cDepend')") or die(mysql_error());
}

The html for the category selector:

<form action="doAddC.php" method="post">
<td><label for="">Category</label></td>
    <td><select name="'CatLevel''CatDepend'">
        <?php
            $result = mysql_query("SELECT * FROM categories");
            while($cat = mysql_fetch_assoc($result)){
        ?>
            <option value="'CatLevel':'<?php echo $cat['Level']; ?>','CatDepend':'<?php echo $cat['cID']; ?>'"><?php echo $cat['Title']; ?></option>
        <?php
            }
        ?>
    </select></td>

doAddC.php

if(isset($_POST['submit'])) {
if(isset($_POST['CatName'])) {
    if(isset($_POST['CatDesc'])) {
        addCat($_POST['CatName'], $_POST['CatDesc'], $_POST['CatLevel']['CatDepend']);
        header("Location: cats.php");
    } else {
        echo "Please Add the Category Description!";
        include('addCat.php');
    }
} else {
    echo "Please Set the Category Name!";
    include('addCat.php');
}
} else {
header("Location: addCat.php");
}

In the best scenario Level and Depending equal to 0 in the database. I don’t even know where to look for this in manuals.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:04:16+00:00Added an answer on May 28, 2026 at 6:04 pm

    The problem has been solved. The code for those who might be struggling with a similar problem as follows.

    HTML snapshot:

    <form action="doAddC.php" method="post">
    <td><select name="CatDepend">
            <option value="<?php
            $depending = "0"; /* Tells that there is no master category */
            $level = "1"; /* Tells that this is the master category (Level 1) */
            $str = "$depending $level";
            echo $str ?>">None</option>
        <?php
            $result = mysql_query("SELECT * FROM categories");
            while($cat = mysql_fetch_assoc($result)){
        ?>
            <option value="<?php
            $depending = $cat['ID']; /* Tells that the ID of the master category is a variable for Depending */         
            $level = ($cat['Level'] + 1); /* Tells that the category level of a new category is +1 */
            $str = "$depending $level";
            echo $str ?>"><?php echo $cat['Title']; ?></option>
        <?php
            }
        ?>
    </select></td>
    

    Snapshot of doAddC.php:

    if(isset($_POST['submit'])) {
        if(isset($_POST['CatName'])) {
            if(isset($_POST['CatDesc'])) {
                addCat($_POST['CatName'], $_POST['CatDesc'], $_POST['CatDepend']);
                header("Location: cats.php");
            } else {
                echo "Please Add the Category Description!";
                include('addCat.php');
            }
        } else {
            echo "Please Set the Category Name!";
            include('addCat.php');
        }
    } else {
        header("Location: addCat.php");
    }
    

    Snapshot of function:

    function  addCat($cName, $cDesc, $cOrder) {
        $part = explode(" ",$cOrder); /* Using explode() break down the value of $str (html snapshot), where a space works as a separator */
        $query = mysql_query("INSERT INTO categories VALUES(null,'$cName','$cDesc', '$part[0]', '$part[1]')") or die(mysql_error());    /* $part[0] and $part[1] put the values into the database as needed /*
    }
    

    Mission accomplished 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the data I have received from a php script,
My PHP knowledge is limited and I am trying to implement http://www.tutorialchip.com/php-download-file-script/ this script
I have very limited knowledge of C#. My goal is to provide a C++
I have very limited knowledge of using C Builder, could you give me an
I recently pickup Java so I have very limited knowledge, but I would like
I have limited knowledge on VB coding. I am now creating a system which
I have limited knowledge of Java-based technologies, and for business enforced reasons, I may
I honestly have only started recently researching this so my knowledge is limited. I
Excuse my ignorance. My knowledge of regular expressions is extremely limited. I have the
I am a web-developer working in PHP. I have some limited experience with using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.