mysqli - Select all from the db -


i need print user in db how do that? can't bind baram because there not thing bind?

here code:

session_start();     require 'inc/connect.php';  $hey = $mysqli->prepare("select * user"); $hey->execute(); $hey->bind_result($all); $hey->fetch(); $hey->close();  echo $all; 

if table user has 7 columns, give bind_result 7 variable names:

$hey->bind_result($column_one, $column_two, $column_three, $column_four, $column_five, $column_six, $column_seven); 

of course, use variable names reflect nature of data represented.

all now:

session_start();     require 'inc/connect.php';  $hey = $mysqli->prepare("select * user"); $hey->execute(); $hey->bind_result($id, $fname, $lname, $email, $phone, $addy, $age); while ( $hey->fetch() ) {   echo "$id $fname $lname $email $phone $addy $age<br>"; } $hey->close(); 

i prefer explicit sql , call columns want in results:

select id, fname, lname, email, phone, addy, age user 

...to protect queries in case columns added table later.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -