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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:10:48+00:00 2026-06-06T00:10:48+00:00

Ok I am having a small issue I am trying to turn this jQuery

  • 0

Ok I am having a small issue I am trying to turn this jQuery to PHP

What I need what to do is place this in a foreach function this is what I do first the jQuery code.

$.each(obj.products, function(i, obj) {

    if(obj.barcode == barcode)
    {
        $("#showmoreinfohere").show();
        $("#moremovietop").html(obj.name.toUpperCase());
        $("img#selectedproduct").attr('src', ''+obj.logoURL+'');
        $("span#perticket").html(obj.price);
        currentproduct["barcode"] = obj.barcode;
        currentproduct["priceperticket"] = obj.price;
        currentproduct["cashbackperticket"] = obj.discount;
        $("span#VIPCashBack").html(obj.discount);
        total = obj.price * $("#qtyselect").val();
        $("span#totalprice").html("$"+total);
    }
});

My PHP CODE

<?php
    $cartdata = $fetch->cartitems($_COOKIE["sessionkey"]);
    foreach ($cartdata as $cart)
    {
        $product_details = $fetch->getbarcode('$cart["barcode]"');
    ?>

    <tr>
        <?php 
        foreach ($product_details as $product)
        {
        ?>

        <td><?php $product['name']?></td>
        <td><?php $product['price']?></td>
        <td><?php $cart['qty']?></td>
        <td><?php $product['discount']?></td>
        <?
        }
        ?>

    <?php
    }

 ?> 

the error I get is

Warning: Invalid argument supplied for foreach() in
/home/movies/public_html/tpl/cart.tpl on line 27

ISSUE from Googling this is what I am finding:

  1. you can do a foreach inside a foreach
  2. JSON for product_details are returning the following

      {
       "_id": ObjectId("4f6ab67338fc5ded4f000000"),
       "company": "village",
       "logo": "http: \/\/...\/villagetop.png",
       "products": {
         "0": {
           "barcode": "236690091",
           "name": "Weekday",
           "logoURL": "http: \/\/...\/ticketpic1.png",
           "price": "12.50",
           "discount": "1.50" 
        },
        ...
      },
       "store_name": "movies" 
    }
    
  • 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-06-06T00:10:51+00:00Added an answer on June 6, 2026 at 12:10 am

    Edit

    Before attempting to find answers, it’s recommended that you add the following two lines at the top of your script:

    error_reporting(-1);
    ini_set('display_errors', 'On');
    

    Edit 2

    From the JSON dump you should use either $product_details->products or $product_details['products'] in your foreach loop, depending on how you called json_decode().


    The following code:

    $product_details = $fetch->getbarcode('$cart["barcode]"');
    

    Not likely to work, the proper code for that it:

    $product_details = $fetch->getbarcode($cart['barcode']);
    

    Inside your loop:

    <td><?php $product['name']?></td>
    

    This does not output anything, you want something like this:

    <td><?php echo htmlspecialchars($product['name']); ?></td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a small bit of trouble trying to get this piece of code
I'm having a bit of an issue trying to get some PHP code to
I am having an issue trying to make a small text-fantasy type game involving
I'm having a small issue here: <div id=navbar> <ul id=navtabs class=floatcontainer> <li <?php if
Im having a small problem with my code. I have been trying to read
I am having a small issue, I am trying to run a $(form#picform).submit after
Im having a small issue today.. I am trying to create an aui as
I'm having a small issue when I'm compiling a template with Handlebars.js . I
I'm having an small issue with SQLXML in SQL Server 2008. Here's my testing
I'm new to LINQ and am having a small issue. I created a DBML

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.