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 6928633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:12:52+00:00 2026-05-27T11:12:52+00:00

I have a mysql table which contains is: folder_id (int(11), auto increment) folder_name (varchar)

  • 0

I have a mysql table which contains is:

folder_id (int(11), auto increment) 
folder_name (varchar) 
folder_class(varchar) 
folder_link (varchar)

What I want to do is somehow loop through the table and store each row like this:

$packs = array( array(  'Name'  => 'DarkUIPack', 
                    'Class' => 'ui',
                    'Link'  => 'http://graphicriver.net/item/dark-minimalist-ui-pack/662762' 
                ),
            array(  'Name'  => 'MinimalistIcons', 
                    'Class' => 'min',
                    'Link'  => 'http://graphicriver.net/item/small-minimalist-icons-pack/670469'
                ),
            array(  'Name'  => 'BlueMediaIcons', 
                    'Class' => 'blue',
                    'Link'  => 'http://graphicriver.net/item/blue-media-icons-set/705319'
                ),
            array(  'Name'  => 'MediaIcons', 
                    'Class' => 'med',
                    'Link'  => 'http://graphicriver.net/item/media-icons-set/679835'
                ),
            array(  'Name'  => 'ToTheTopButtons', 
                    'Class' => 'top',
                    'Link'  => 'http://graphicriver.net/item/to-the-top-buttons/673221'
                ),
            array(  'Name'  => 'Sunglasses', 
                    'Class' => 'sun',
                    'Link'  => ''
                ),
            array(  'Name'  => 'RealEstate', 
                    'Class' => 'est',
                    'Link'  => 'http://graphicriver.net/item/simple-real-estate-logo/724697'
                ),
            array(  'Name'  => 'PhotoStudio', 
                    'Class' => 'std',
                    'Link'  => 'http://graphicriver.net/item/photo-studio-logo/724694'
                ),
            array(  'Name'  => 'PayDayCity', 
                    'Class' => 'std',
                    'Link'  => ''
                ),
            array(  'Name'  => 'MoleculeCorp', 
                    'Class' => 'mol',
                    'Link'  => 'http://graphicriver.net/item/molecule-corp-logo/719307'
                ),
            array(  'Name'  => 'ClubbGX', 
                    'Class' => 'gx',
                    'Link'  => ''
                ),
            array(  'Name'  => 'AerialVision', 
                    'Class' => 'aer',
                    'Link'  => ''
                ),
            array(  'Name'  => 'ServiceCompany', 
                    'Class' => 'ser',
                    'Link'  => 'http://graphicriver.net/item/service-company-logo/727091'
                ),
            array(  'Name'  => 'ElectroTech', 
                    'Class' => 'ele',
                    'Link'  => 'http://graphicriver.net/item/electro-tech-logo/720904'
                ),
            array(  'Name'  => 'CreativeStudio', 
                    'Class' => 'cre',
                    'Link'  => 'http://graphicriver.net/item/creative-studio-logo/719494'
                ),
            array(  'Name'  => 'NanoCorp', 
                    'Class' => 'nan',
                    'Link'  => 'http://graphicriver.net/item/nano-corp-logo/719098'
                ),
            array(  'Name'  => 'RehabPlace', 
                    'Class' => 'reh',
                    'Link'  => ''
                ),
            array(  'Name'  => 'MyLocalMix', 
                    'Class' => 'mix',
                    'Link'  => ''
                ),
            array(  'Name'  => 'SevenBySeven', 
                    'Class' => 'sev',
                    'Link'  => ''
                ),
            array(  'Name'  => 'ComingSoon', 
                    'Class' => 'com',
                    'Link'  => ''
                ),
            array(  'Name'  => 'AlienIcons', 
                    'Class' => 'aln',
                    'Link'  => 'http://graphicriver.net/item/alien-icons-set/698515'
                ),
            array(  'Name'  => 'PreloaderPortfolio', 
                    'Class' => 'pre',
                    'Link'  => ''
                ),
            array(  'Name'  => 'BioTech', 
                    'Class' => 'bio',
                    'Link'  => ''
                ),
            array(  'Name'  => 'ConstructionCompany', 
                    'Class' => 'con',
                    'Link'  => ''
                ),
            array(  'Name'  => 'EagleMedia', 
                    'Class' => 'egl',
                    'Link'  => ''
                ),
            array(  'Name'  => 'ElectronicWays', 
                    'Class' => 'elw',
                    'Link'  => ''
                ),
            array(  'Name'  => 'EnvironmentalCompany', 
                    'Class' => 'env',
                    'Link'  => ''
                ),
            array(  'Name'  => 'SecureData', 
                    'Class' => 'sec',
                    'Link'  => 'http://graphicriver.net/item/secure-data-company-logo/907334'
                ),
            array(  'Name'  => 'ConstructSimple', 
                    'Class' => 'cns',
                    'Link'  => 'http://graphicriver.net/item/simple-construction-company-logo/907538'
                ),
            array(  'Name'  => 'ConstructRoof', 
                    'Class' => 'cnr',
                    'Link'  => 'http://graphicriver.net/item/construction-company-logo/907549'
                )
        );  

where ‘Name’ corresponds to folder_name, ‘Class’ to folder_class and ‘Link’ to folder_link.

I’m using this within a class and the class looks like this till now:

class folder
{
private $connect;

public function __construct() {

    $this->connect = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

    if (mysqli_connect_errno()) {
        $error = true;
        $message['error'] = true;
        $message['message'] = mysqli_connect_error();
        return json_encode($message);
    }
        else {
            return true;    
        }

}

    public function crtFolder($fldName,$fldClass,$fldLink,$fldPath) {

    $fldName = preg_replace('/\s+/', '', $fldName);

    $fldPN = $fldPath."\\".$fldName;

    $modArray = array(array('1'));

    if ((!is_dir($fldPN))) {
        if(mkdir($fldPN,0777,true)) {

            $sql = "INSERT INTO folders (folder_name,folder_class,folder_link) VALUES (?, ?, ?)";

            if($stmt = $this->connect->prepare($sql)) {
                $stmt->bind_param("sss", $fldName, $fldClass, $fldLink);
                $stmt->execute();
                $stmt->close();
                $error = false;
                $message['error'] = false;
                $message['message'] = "Folder Created | Data Successfuly Inserted";
                return json_encode($message);
            }
                else {
                    $error = true;
                    $message['error'] = true;
                    $message['message'] = "Folder Created | Data Failed To Insert";
                    return json_encode($message);
                }
        }
            else { 
                $error = true;
                $message['error'] = true;
                $message['message'] = "Folder Failed To Create";
                return json_encode($message); 
            }
    }
        else {
            $error = true;
            $message['error'] = true;
            $message['message'] = "Folder Already Exists";
            return json_encode($message);   
        }
}

public function __destruct() {

    $closeConnection = $this->connect->close();

    if($closeConnection) {
        return true;
    }
}

}

I’m showing the class because I want to keep the same method for the creating the array as the other methods are created. Because I found something on Google, but it was making an array from multiple tables. I only have one table.

  • 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-27T11:12:52+00:00Added an answer on May 27, 2026 at 11:12 am

    Write below given function in to your class. Hope this will help things.

    public function getTableData(){
    
     $sql = "SELECT * FROM folders";
     if($stmt = $this->connect->prepare($sql)) {
    
         $stmt->execute();
         $stmt->close();
         $arrFinalArray = array();
         while ($arrFolder = $stmt->fetch()){
    
            $arrFinalArray[] = array(
                        'Name'  => $arrFolder['folder_name'], 
                        'Class' => $arrFolder['folder_class'],
                        'Link'  => $arrFolder['folder_link']
            );
    
    
         }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL table which contains a number of products. What I want
i have a large mysql database table in which one column contains values ranging
Greetings friends, In my MySQL database, I have 'MAB' table which contains information about
Hi I have a field in mySql table called jobnumber which auto increments with
I have a mySQL table which contains rows based on payments. Each row contains
I have a mysql legacy table which contains an client identifier and a list
I have this MySQl database that has a table which contains a column that
I have an html table which contains records, comes from mysql db. Each row
I have a table with a field which contains strings in my MySQL database.
I have a MySQL table which contains comma-separated values like this: first row=(3,56,78,12) second

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.