Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Thanked 1 Time in 1 Post

    populating the category and subcategory

    In my sql db I've got a table with a category and a subcategory.
    Now I want to extract all values and place them in a javascript file.

    The javascript file looks like this:
    parent_array['Audi'] = ['A3','A4','A5','A6','A8','Q5','Q7','S3','S4','S5','S6','S8','RS6'];
    parent_array['Dacia'] = ['Sandero','Logan'];
    parent_array['FIAT'] = ['Bravo','Punto','Grande Punto'];
    As you can see there are categories and subcategories in the javascript part.
    How can I retrieve my db categories and subcategories to place them in the javascript.

    I don't know which sql statement I should use, I got this part but don't know how to continue.

    $q = mysql_query("select * from mydb");

    if(!$q) {echo "A DB error occured, please try again later. Error: ". mysql_error();}else{
    while($nv=mysql_fetch_array($q)) {$valueFromDb = $nv['Category']; $valueFromDb2=$nv['Subcategory'];

    /* Do some stuff here */



  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    What are your tables designed like?


    Posting Permissions

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