Jump to content

sprinting my table


Namtip

Recommended Posts

1: whats the point of printf? I mean can't you just make do with sprintf?

2:How do you go about putting the following table into sprintf?

$query = 'INSERT INTO order_details
    (order_id, order_qty, product_code, buyer_id, name_id)
SELECT
    ' . $order_id . ', qty, product_code, ' . $_SESSION['name_id'] . ', name_id
FROM
    cart
WHERE
    session = "' . $session . '"';
mysql_query($query, $db) or (mysql_error($db));

 

I've checked google for both questions. If you think I'm being cheeky could you just answer my first question and ignore my second. :)

Link to comment
Share on other sites

Thanks for the response Thorpe, the query is copied directly from my text book except for the names of the column and tables, but apart from that the layout is exactly the same. It just selects the information from the users cart and enters it into orders before the cart information is deleted. It works as intended but I guess theres prolly a better way. :D

So I guess I have to use printf too. :( Thanks for the information.

Link to comment
Share on other sites

$query = sprintf("INSERT INTO order_details
    (order_id, order_qty, product_code, buyer_id, name_id)
SELECT
    %d, qty, product_code, '%s', name_id
FROM
    cart
WHERE
    session = '%s'", $order_id, mysql_real_escape_string($_SESSION['name_id']), $session);
mysql_query($query, $db) or (mysql_error($db));

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.