Prepared SQLi & SELECT
Posted: Thu Jun 17, 2010 5:13 pm
I've recently started moving over to the mysqli_query methods as opposed to the old mysql_query methods, and have hit a roadblock - using prepared statements. What I would like to do is do a simple SELECT query. Non-prepared, I would do this:
However, I don't know how to get the results from a prepared statement - in any way! I know how to execute queries on the database, just not how to get the results! I have tried doing something along the lines of:But then, I don't know how to get the results of this query! Any pointers, functions etc. would be a great help.
EDIT: I generally work in a procedural style, but am trying to learn OOP
Code: Select all
$result = mysqli_query($con,"SELECT * FROM `".$page_table."` ORDER BY id DESC LIMIT ".$page_start." , ".$page_limit_no);
$results = mysqli_fetch_array($result));Code: Select all
$stmt = mysqli_stmt_init($con);
if(mysqli_stmt_prepare($stmt, "SELECT * FROM 'sqltrial' WHERE usr = ? AND pass = ?"))
{
mysqli_stmt_bind_param($stmt, 'ss', $usr, $pass);
$usr = 'annexample';
$pass = 'passw0rd';
mysqli_stmt_execute($stmt));
}EDIT: I generally work in a procedural style, but am trying to learn OOP