davefootball123 Posted March 31, 2013 Share Posted March 31, 2013 I have a script seen below that queries a MYSQL database. It works fine for getting the first result however I need to get all the results. Can someone help me with this? Thanks very much, Dave. $sql ="SELECT map FROM onwarn WHERE type='SPECIAL WEATHER STATEMENT'"; $results = mysqli_query($connect,$sql); $location = mysqli_fetch_($results); foreach($location as $subregion) { echo '<img style="position:absolute;left:50%;; margin-top:15px" src="/WWAMAP/SpecialWeatherStatements/'.$subregion.'.png" border="0">'; } mysqli_close($connect); Quote Link to comment Share on other sites More sharing options...
Barand Posted March 31, 2013 Share Posted March 31, 2013 turn error reporting on, look at the error messages produced. Quote Link to comment Share on other sites More sharing options...
davefootball123 Posted March 31, 2013 Author Share Posted March 31, 2013 (edited) turn error reporting on, look at the error messages produced. Thanks for the response Barand...there is no error. It does display the image...however it doesn't get each result. From what I know mysqli_fetch_row only gets the first result...unless im wrong. Edited March 31, 2013 by davefootball123 Quote Link to comment Share on other sites More sharing options...
Jessica Posted March 31, 2013 Share Posted March 31, 2013 Did you look at the manual? There's great examples. Quote Link to comment Share on other sites More sharing options...
davefootball123 Posted March 31, 2013 Author Share Posted March 31, 2013 Did you look at the manual? There's great examples. Hi Jessica, thank you for your response. To get all mysqli results what kind of function would I need to look at? I looked at mysqli fetch_all but I'm unsure if that is what I need. Quote Link to comment Share on other sites More sharing options...
Barand Posted March 31, 2013 Share Posted March 31, 2013 Thanks for the response Barand...there is no error. That's odd - you are calling a function that does not exist $location = mysqli_fetch_($results); Quote Link to comment Share on other sites More sharing options...
davefootball123 Posted March 31, 2013 Author Share Posted March 31, 2013 That's odd - you are calling a function that does not exist Whoops sorry, was supposed to be this...hit ctrl z too many times lol $location = mysqli_fetch_row($results); Quote Link to comment Share on other sites More sharing options...
davefootball123 Posted April 1, 2013 Author Share Posted April 1, 2013 I tried some code...I get "Call to undefined method mysqli_result::fetch_all() in /home/sowx/public_html/dbget.php on line 15" $connect = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die ("Couldn't connect to warning server"); $sql ="SELECT map FROM onwarn WHERE type='SPECIAL WEATHER STATEMENT'"; $result_db = $connect->query($sql) or die ("Error!"); $all_result = $result_db->fetch_all(); foreach($all_result as $subregion) { echo '<img style="position:absolute;left:50%;; margin-top:15px" src="/WWAMAP/SpecialWeatherStatements/'.$subregion.'.png" border="0">'; } mysqli_close($connect); Quote Link to comment Share on other sites More sharing options...
davefootball123 Posted April 1, 2013 Author Share Posted April 1, 2013 Fixed...simple fix. Thanks for your support. $connect = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die ("Couldn't connect to warning server"); $sql ="SELECT map FROM onwarn WHERE type='SPECIAL WEATHER STATEMENT'"; $result_db = $connect->query($sql) or die ("Error!"); while ($row = $result_db->fetch_assoc()) { foreach ($row as $subregion) { echo '<img style="position:absolute;left:50%;; margin-top:15px" src="/WWAMAP/SpecialWeatherStatements/'.$subregion.'.png" border="0">'; } } 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.