Search the Community
Showing results for tags 'data retrieval'.
-
Ok so more on my lil comic app... (and all was going so well) GOAL: Trying to take a value from a form and create sql statement to look for that comic title in the DB and show what has been entered. (I.E search for Spider-Man -> Shows all Rows that Pertain to Spider-Man) So I can't figure out what is wrong with my code. Soon as I enter in my while statement my php failes however my query seems to be doing just fine. I've used the same kind of template on other pages and it works just fine the only difference is when I added a WHERE statement to my sql query. * NOTE: If I take the output of my query and plug it into mysql workbench I get the correct tables and results so I'm yeah kinda confused. * NOTE: The way I retrieve the $data variable is from a query from the form page which pulls all the comic names from the DB and displays in a drop down so the values that it passes are the exact same names / titles from the DB itself. <?php require('./scripts/con_db.php'); // Query DB for Comic_Names // $data = $_POST['comic_name']; $query = "SELECT * FROM `comic_db`.`comic_db` WHERE `comic_name`='$data'"; $com_sql = mysqli_query($comic_connect, $query); if (!$com_sql){ echo "Failed to connect to db" . mysqli_errorno(); } ?> <body> <p align="center"><img src="./images/comic_front.png" /></p> <table align="center"> <tr> <?php while($row = mysqli_fetch_array($com_sql)) { echo "<td>" .$row "</td>"; } ?> </tr> </table> <br /> <br /> <?php require('./scripts/footer.php'); ?> I should also say i've tried these other passes as well with no luck : <?php while($row = mysqli_fetch_assoc($com_sql)) { echo "<td>" .$row "</td>"; } ?> while($row = mysqli_fetch_assoc($com_sql)) { echo "<td>" .$row['comic_name'] "</td>"; } ?> <?php while($row = mysqli_fetch_assoc($com_sql)) { echo "<td>" .$row['$data'] "</td>"; } ?> I've also tried something I found in a book that says to do extract($row) then do my echo "<td>" .$row "</td>"; but that didn't work either so I'm missing something here is what the output for the SELECT string gives me as well from the browser which seems to be fine and again if I plug into mysql workbench it displays what I need.. SELECT * FROM `comic_db`.`comic_db` WHERE `comic_name`='Iron Man - V5' TY for help guys I've try to keep the ??'s down but I'm missing something (probably pretty obvious) so I need some guidence.