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
https://forums.phpfreaks.com/topic/217414-sprinting-my-table/
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
https://forums.phpfreaks.com/topic/217414-sprinting-my-table/#findComment-1128998
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
https://forums.phpfreaks.com/topic/217414-sprinting-my-table/#findComment-1129002
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.