Which would be the most efficient?

Discussion in 'PHP' started by Dakafall, Jun 28, 2010.

  1. #1
    I am trying to make a website menu using PHP and MySQL and Javascript / AJAX.

    Would it be more efficient to cut MySQL out of the picture and use arrays to to define the menu items?

    Example :

    //*** Menu Options ***\\
    	//*** About Us ***\\
    	$about[0] = "About Us";
    	$about[1] = "Contact Us";
    	$about[2] = "News ";
    	$about[3] = "Testimonials";
    	
    	//*** Services ***\\
    	$services[0] = "Services";
    	$services[1] = "Internet Access";
    	$services[2] = "Web Hosting";
    	$services[3] = "Network Consulting";
    	
    	//*** Support Center ***\\
    	$support[0] = "Support Center";
    	$support[1] = "Dial Up";
    	$support[2] = "DSL";
    	$support[3] = "Wireless";
    	$support[4] = "E-Mail";
    	$support[5] = "Security";
    	$support[6] = "Web Hosting";
    	$support[7] = "Network Information";
    	$support[8] = "Download Software";
    	
    	//*** Members Area ***\\
    	$members[0] = "Members Area";
    	$members[1] = "E-Mail";
    	$members[2] = "LD Rates";
    PHP:
    Or would it be more efficient to use a MySQL table and get the menu items from there.

    I dont have an example for the MySQL menu because I havnt gotten that far yet in my learning.
     
    Dakafall, Jun 28, 2010 IP
  2. frank100

    frank100 Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well when ever somebody has to add a menu item she will have to search you to hard code....and upload this may be menu.php using some ftp client...
    where as with mysql option...a novice user can use a admin gui to add an item
     
    frank100, Jun 28, 2010 IP
  3. Dakafall

    Dakafall Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So, I would create a table for each different section of the menu, and add value according to the sub menus? I then would call a query to fill the tables?
     
    Dakafall, Jun 29, 2010 IP
  4. Zerix

    Zerix Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    PHP would be more efficient in terms of processing time but MySql would mean that it is more flexible. If you were doing it just the PHP way you may as well cut out the PHP part?
     
    Zerix, Jun 29, 2010 IP
  5. imperialDirectory

    imperialDirectory Peon

    Messages:
    395
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can use MySQL and cache the result. That way the menu info can be read once and cache as long as you want it to expire (or expire it whenever you make changes). Its fast and flexible.
    If you run Linux, you can try memcache or memcached. If you run Windows, then use wincache
     
    imperialDirectory, Jun 29, 2010 IP