Im new to PDO, heard that this is the better method to do web applications, and im developing small billing application. Having one dobut, can i do coding like below?
<?php require_once '../../classes/PDO_connection.php'; $type = 'initial_stock'; $item_code = $_POST["item_code"]; $category = $_POST["category"]; $variety = $_POST["variety"]; $quantity = $_POST["quantity"]; $price = $_POST["price"]; $f_price = number_format($price, '2', '.', ''); $total = $quantity * $price; $full_name = $item_code.':'.$category.':'.$variety.':'.$f_price; $in_stock = $quantity; $prev_stock = ''; //inserting data from initial stock page $stmt = $pdo->prepare("INSERT INTO silk (type, item_code, category, variety, quantity, price, full_name, total, in_stock, sale_date, entered_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())"); $stmt->bindParam(1, $type); $stmt->bindParam(2, $item_code); $stmt->bindParam(3, $category); $stmt->bindParam(4, $variety); $stmt->bindParam(5, $quantity); $stmt->bindParam(6, $price); $stmt->bindParam(7, $full_name); $stmt->bindParam(8, $total); $stmt->bindParam(9, $in_stock); $stmt->execute(); //getting all initial stock for dispaling $stmt = $pdo->prepare("SELECT * FROM silk WHERE type='initial_stock'"); $stmt->execute(); $rows = $stmt->fetchAll(); foreach($rows as $stock){ echo "<tr class='active'> <td>".$stock['item_code']."</td> <td>".$stock['category']."</td> <td>".$stock['variety']."</td> <td>".$stock['price']."</td> <td>".$stock['quantity']."</td> <td><a id='initial_stock_silk_delete' id_to_delete=".$stock['id'].">Delete</a></td> </tr>"; } In mysql, i call the function that has query and return the value, but i thought PDO no need that? am i correct? expecting proffesionals advice.... thanks.