php - Getting ID of Variable in database -


i id of item in database, set variable, , use it. i'm quite new coding stuff. i'm basing on.

http://jameshamilton.eu/content/simple-php-shopping-cart-tutorial?phpsessid=99d373741727e3010a32319f1ebed001

cart.php?action=add&pdin=fbs  $product = $_get[pdin]; 

i can't use integer 'pdin' so, id use corresponding id integer , plug line of code takes integers?

$sql = sprintf("select * products pdin = %d;", $product); 

so in take $product = 'pdin' find it's id $id = 'id' , plug in above code

$sql = sprintf("select * products id = %d;", $id); 

i tried reading on sql select where... confused me some

i'd use prepared statement make bit safer sql injection. database interface using php mysql?

here's 1 option:

$product = $_get['pdin']; $stmt = $db->prepare("select * products pdin = ?"); $res = $db->getassoc($stmt,$product); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -