Sunday, 15 April 2012

Result binding in mysqli -



Result binding in mysqli -

in next example, can folks show me how code binding part select fields table

$stmt = $mysqli_conn->stmt_init(); if ($stmt->prepare("select * books")) { $stmt->execute(); $stmt->bind_result( **what set here** ); $stmt->close(); }

in bind_result, set in variables want fetch info into, instead of using array returned otherwise.

$stmt->bind_result($col1, $col2, $col3, $col4); while($stmt->fetch_assoc()) echo "$col1 $col2 $col3 $col4";

alternatively, if don't want bind result

while($resultarray = $stmt->fetch_assoc()) { echo "$resultarray[columnname1] $resultarray[columnname2] ..."; }

mysqli

No comments:

Post a Comment