Wednesday, May 23, 2012

Selecting stored in variable

Hi I'm trying to create a shopping cart for a college assignment, I'm trying to load a table from the contents of a variable but regardless of what I do it won't recognise its contents.



Here the code snippet



$sql = sprintf("SELECT name, description, price FROM %s WHERE id = %d;",$table, $product_id);
$result = mysql_query($sql);



The table variables contents is being missed out so its looking a nameless table, I've searched Google and found a couple of examples but are working for me.



Does anyone have any ideas?



Thanks Scott.





No comments:

Post a Comment