in Education by
I am trying to echo out an array using for each but it's not displaying any values. The only values i can echo out is within a second for each. Can anyone tell me what i'm doing wrong? What i am trying to echo is the price, item, description etc but i am getting nothing. If you need to see the output of the array it's here http://operationbraveheart.org.uk/jcart/testshop.php while ($row = $result->fetch()) { $superitem[$row['itemid']][] = $row; } foreach($superitem AS $subitem) { list($prodid,$item,$size,$description,$price) = $subitem[0]; if ($count % NUMCOLS == 0) echo ""; # new row echo ''; var_dump($subitem); //Your normal code up until the select box... echo '
'; if(count($subitem) > 1) { echo ' "; } else { echo ' '; } echo'Price: $'.$subitem['price'].'
'; echo ''; $count++; $counter++; if ($count % NUMCOLS == 0) echo "\n"; # end row } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Current it looks like $subitem contains an array of length 1 where the first index is a row. Change... $superitem[$row['itemid']][] = $row; should be... $superitem[$row['itemid']] = $row; and... list($prodid,$item,$size,$description,$price) = $subitem[0]; should be... list($prodid,$item,$size,$description,$price) = $subitem;

Related questions

0 votes
    I am trying to echo out an array using for each but it's not displaying any values. The only ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I have a $_GET[q] from the URL. I am trying to ECHO the search term back into the search box. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I have a $_GET[q] from the URL. I am trying to ECHO the search term back into the search box. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    What is the difference between “echo” and “print” in PHP?...
asked Jul 13, 2021 in Education by JackTerrance
0 votes
    I installed PEAR and when I try to run it, I receive this message: PHP_PEAR_PHP_BIN is not set correctly ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    What can’t we put into an array or dictionary?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    I currently have 2 classes: workerListClass workerClass The workerListClass gets a list of work with ids from ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    How to solve array problem? $kuponlar = $core->query("SELECT * FROM kupon WHERE kupon_durum = ?", ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    How to solve array problem? $kuponlar = $core->query("SELECT * FROM kupon WHERE kupon_durum = ?", ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    Question Type: Single-Select vars: score: 3 tasks: - shell: echo "**** on!! You won." when: ?? How do you use a variable to apply ... 3. when: score == 3 4. when: {{ score }} == 3...
asked Jan 26, 2023 in Technology by JackTerrance
0 votes
    Recently, I am trying to write a simple version of Linux command more. In order to do that, I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
...