php - echo result as part of bind_param -


i trying use code in order echo information, required have bind_param, in order generate data. changes need make code in order work?

function get_header_link($sql, $image) {     include 'connect.php';      $id = $_get['id'];     $select = $conn->prepare($sql);     $select->bind_param('s', $id);     if ($result = $select->execute()) {         foreach($select $value => $row) {             echo "<h4>" . $row['display'] . "</h4>\n                     <div class='placeholder' id='large'>\n                         <img src='" . $row[$image] . "'/>\n                         <div class='name'>                             <h1>" . $row['display'] . "</h1>\n                         </div>                   </div>";         }     } } 

on running code above, using:

get_header_link("select * homelinks linkid=?", "large_image"); 

i no longer error, , none of data database printing.

after reading this, should use mysqli this:

function get_header_link($sql, $image) {     include 'connect.php';      $id = $_get['id'];     $select = $conn->prepare($sql);     $select->bind_param('s', $id);     $select->execute();     $select->store_result();     $meta = $select->result_metadata();     while ($field = $meta->fetch_field()) {         $params[] = & $row[$field->name];     }      // bind columns in $row     call_user_func_array(array(         $select,         'bind_result'     ) , $params);      while ($select->fetch()) {         echo "<h4>" . $row['display'] . "</h4>\n                 <div class='placeholder' id='large'>\n                     <img src='" . $row[$image] . "'/>\n                     <div class='name'>                         <h1>" . $row['display'] . "</h1>\n                     </div>                 </div>";     }      /* close statement */     $select->close(); } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -