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.
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
Post a Comment