totallytech Posted April 24, 2018 Share Posted April 24, 2018 Hey Guys, I'm going mad - why is this generating no record found. $id = $_GET["id"]; $table_name="tbl123"; $rows = $wpdb->get_results("SELECT * FROM $table_name WHERE photo_id = $id"); if ($rows->num_rows > 0) { foreach ($rows as $row) { echo "<img src='.$photo_dir.$row->photo_id.' class='zoom'>"; } } else { echo "<h2>Error:</h2>Please check the Image Reference and enter again."; } but if I go in to phpmyadmin and do a direct sql search for this, I see 1 record... SELECT * FROM `tbl123` WHERE `photo_id` = "1594" Why am I not getting anything returned? Am I parsing something wrong? Quote Link to comment Share on other sites More sharing options...
requinix Posted April 24, 2018 Share Posted April 24, 2018 When in doubt, read the documentation. Are you using get_results() correctly? Quote Link to comment Share on other sites More sharing options...
totallytech Posted April 24, 2018 Author Share Posted April 24, 2018 When in doubt, read the documentation. Are you using get_results() correctly? Ah! I was, but not.... it needed to be SELECT * FROM $table_name WHERE photo_id = '$id' Rookie mistake - I've been looking at code for about 9 hours now... might be time to walk away lol! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.