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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:25:42+00:00 2026-06-14T03:25:42+00:00

I have built a simple webshop, where i need to process ordered products. The

  • 0

I have built a simple webshop, where i need to process ordered products. The order comes in very nice with the id of the ordered product.

I want the name and price of the product displayed on the page where i show all details about of the order. Too bad it doesn’t work..

This is my attempt:

code to fetch product(s) ordered:

$query2 = mysql_query("SELECT * FROM orders_products WHERE order_id='".$_GET['order']."'");
while ($line2 = mysql_fetch_assoc($query2))
{
$row2[] = $line2;
$smarty->assign('row2', $row2);
}

(attempt to) fetch product name and price:

$query4 = mysql_query("SELECT * FROM products WHERE id ='".$row2['product_id']."'");
while ($line4 = mysql_fetch_assoc($query4))
{
$row4[] = $line4;
$smarty->assign('row4', $row4);
}

displaying it (excuse me for some dutch words in the html):

                <div class="module">
                <h2><span>Bestelde Producten</span></h2>
                {section name=row2 loop=$row2}
                 {section name=row4 loop=$row4}
                <div class="module-table-body">
                    <table id="bestelling" class="bestelling">
                        <thead>
                            <tr>
                                <th style="width:3%">#</th>
                                <th style="width:10%">Naam</th>
                                <th   style="width:10%">Bedrag</th>                         
                                <th style="width:3%">Aantal</th>                                    
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>{$row2[row2].id}</td>
                                <td>{$row4[row4].name}</td>
                                <td>{$row4[row4].price}</td>
                                <td>{$row2[row2].product_amount}</td>

                            </tr>
                        </tbody>
                    </table></br>
                    <p><strong>Totaal: </strong></br>
                    <strong>BTW (21%): </strong></p>
                    </br>
                     <p><strong>Totaal Inclusief BTW: </strong></p>
                     {/section}
                    <div style="clear: both"></div>
                 </div> <!-- End .module-table-body -->         
                 </div>     
                 </div> 

orders_products table:

id order_id product_id product_amount

products table:
id category_id name description slug price in_stock


Thanks guys for your answers! Kami’s code worked out for me.

How i have it now:

$queryx = mysql_query("SELECT * FROM products inner join orders_products on products.id = orders_products.product_id WHERE order_id = '".mysql_real_escape_string($_GET['order'])."'");

while ($linex = mysql_fetch_assoc($queryx))
{
$rowx[] = $linex;
$smarty->assign('rowx', $rowx);
}

Do you think this is safe? I will start using mysqli or PDO eventually, but i find it too dificult as i am still a beginner..

Do you know any good guides about securing php -> mysql?

Thanks so far!

  • 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-14T03:25:43+00:00Added an answer on June 14, 2026 at 3:25 am

    try

    $queryx = mysql_query("SELECT * FROM products inner join orders_products on products.id = orders_products.product_id WHERE order_id = " . $_GET['order']);
    
    while ($linex = mysql_fetch_assoc($queryx))
    {
        $rowx[] = $linex;
        $smarty->assign('rowx', $rowx);
    }
    

    I am doing join to link the data together through one query. This will allow you to have all the product info in one query. Your issue I suspect are the quotes around order_id='".$_GET['order']."'".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a very simple internal messaging system inside my application, i want
I have built a simple TCP server and need to compare client input with
I have built a very simple blog application using Ruby on Rails. New to
I have built a simple website monitoring application using Indy TIdhttp component. I want
I have built a variety of little scripts using Ruby's very simple Queue class,
I have built a very simple CakePHP website using the Auth component and have
I am just starting out in xCode and I have built a very simple
I am very much an Android newbie and I have built a simple RSS
I have built a simple menu in jQuery http://vanquish.websitewelcome.com/~toberua/ Here is a sample of
Hi I have built a simple WCF application I am using to query data

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.