Reusing php prepared statement will only return last entry of mysql table -
i'm encountering unusual problem. honest first time seek re-use prepared statement on same php page. in case need work since solution of doing 2 identical statements different variable names seems redundant. anyway here's did.
$mysqli = new mysqli(host,user,password,database); $image_from_database = $mysqli->prepare("select slider_id, slider.images_id, images.images_id, images.image_name, images.image_path, images.image_type, images.image_size, image_tag_name, image_tags.date slider left bring together images on slider.images_id = images.images_id left bring together image_tags on image_tags.images_id = images.images_id"); $image_from_database->bind_result($sliderid,$sliderimageid,$imageid,$imagename,$imagepath,$imagetype,$imagesize,$tagname,$tagdate); $image_from_database->execute(); $image-from_database->store_result();
then call:
<div class="large-6 columns"> <fieldset class="slider_control"> <legend>images database</legend> <div class="slider_image_edit"> <div class="slider"> <?php while($image_from_database->fetch()){ if(!empty($sliderid)){ echo' <div><img src="../'.$imagepath.'"></div>'; } } $image_from_database->free_result(); ?> </div>
then later on page want display results in table instead of image slider...
<fieldset> <legend>choose different images edit, can view slider see order in</legend> <form action="" method="post" enctype="multipart/form-data"> <table> <thead> <th>id</th> <th>name</th> <th>tag</th> <th>type</th> <th>size</th> <th>edit</th> <th>delete</th> </thead> <tbody> <?php $image_from_database->execute(); while($image_from_database->fetch()){ echo ' <tr> <td>"'.$sliderid.'"</td> <td>"'.$imagename.'" </td> <td>"'.$tagname.'" </td> <td>"'.$imagetype.'" </td> <td>"'.$imagesize.'" </td> <td>edit</td> <td>delete</td></tr>'; } ?> </tbody> </table> </form> </fieldset>
when load page, slider display corresponding images, on list display lastly row of table in particular illustration display like:
id name tag type size edit delete "2" "bf535be38b469cfbcf6db6d02ba3a9d0.jpg" "colleges & programs" "image/jpeg" "82993" edit delete "2" "bf535be38b469cfbcf6db6d02ba3a9d0.jpg" "colleges & programs" "image/jpeg" "82993" edit delete
the edit , delete dont @ time, there placeholders want later on.
anyway, can tell me why query work on first part of page not on sec one?
this because showed records , array got database @ it's end. when phone call again, start last.
do jeroen told you, store result in variable or , reset it.
php mysql
No comments:
Post a Comment