vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   RESOLVED Does this Query have a chance? (https://vborg.vbsupport.ru/showthread.php?t=200261)

Dismounted 01-02-2009 05:32 AM

You don't seem to be looping the $menus_array, but rather, just referencing it using a set key. So I don't know what the order of the array has to do with anything.

Dax IX 01-02-2009 05:45 AM

I'll study it a little more, but this seems to give me EXACTLY what I'm looking for:

PHP Code:

$planner_rows 3;
$planner_columns 7;
$meals = array("Breakfast","Lunch","Dinner");
$days_of_week = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

if(
$vbulletin->userinfo['userid']){

$planners $vbulletin->db->query_read("
    SELECT *
    FROM " 
TABLE_PREFIX "planners
    WHERE memberid = " 
$vbulletin->userinfo['userid'] . "
    ORDER BY id DESC LIMIT 1
"
);



$planners_array = array();
$planners_array[] = $vbulletin->db->fetch_array($planners);

$menuids $planners_array[0][menuids];

$menus $vbulletin->db->query_read("
    SELECT id, shortdescription
    FROM " 
TABLE_PREFIX "menus
    WHERE id IN (
$menuids)
"
);

}

$menus_temp = array();
while (
$menu $vbulletin->db->fetch_array($menus))
{
    
$menus_temp[$menu[id]] = $menu;
}

$menus_array = array();
$id_order explode(','$menuids);

foreach (
$id_order AS $id)
{
    
$menus_array[] = $menus_temp[$id];
}

echo 
"<table style='border:none;width:1070px;'>
    <tr>
        <td style='border:none;width:70px'>&nbsp;</td>"
;
for(
$n 0$n $planner_columns$n++) {
    echo 
"        <td style='color:#FF0000;width:140px;border:none;padding:5px;'><strong>" $days_of_week[$n] . "</strong></td>";
}
echo 
"    </tr>";
for(
$i 0$i $planner_rows$i++) {
    echo 
"    <tr>
        <td style='color:#FF0000;width:70;border:none;text-align:right;padding-right:5px;'><strong>" 
$meals[$i] . "</strong></td>";
        
$list_menu $i;
        for(
$ii 0$ii $planner_columns$ii++) {
            echo 
"<td style='width:140;border:1px solid black;padding:5px;'>" . ($list_menu +1) . " " $menus_array[$list_menu]['shortdescription'];

            
$list_menu += $planner_rows;
            echo 
"</td>";
        }
    echo 
"</tr>";
}
echo 
"</table>"

Thank you so much for your help! :)

I'm not sure exactly how yet, but originally it was listing the menu descriptions in the order that they were entered into the database instead of by the order that they're listed in $menuids. But with your help I was able to get them to display exactly how I want them.

Thank you again!

--------------- Added [DATE]1230882971[/DATE] at [TIME]1230882971[/TIME] ---------------

Unless you have something that you really want to point out with this script the way I have it, this can be marked as SOLVED.

Thanks again! :)


All times are GMT. The time now is 11:21 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01598 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete