comparebest Posted January 7, 2011 Share Posted January 7, 2011 Ok, just another noob problem here while working with PHP + MySQL: I have a php page containing a form which I use to pull the data from mysql database. When the user chooses a value/values from the dropdown lists and clicks submit, the page reloads and displaying the quarry results according to user's selection. When user first loads the php page with form, it shows no data unless he clicks submit. Question: How to show a default quarry value on first page load before user even get to use the form? In other words, I want the user to see the default quarry data pulled from DB on page load before he uses the form to refine the results... I am not sure if its possible, but truly hope so I would appreciate any advice or pointer in the right direction. Please let me know if you need the exact code I am using for my form page. Quote Link to comment https://forums.phpfreaks.com/topic/223719-show-a-certain-quarry-when-page-with-form-first-loaded/ Share on other sites More sharing options...
dropkick_pdx Posted January 7, 2011 Share Posted January 7, 2011 Your code would be helpful for sure. There are slew of ways you can approach this, but it's hard to make a useful recommendation without knowing how you're doing what you're already doing. Quote Link to comment https://forums.phpfreaks.com/topic/223719-show-a-certain-quarry-when-page-with-form-first-loaded/#findComment-1156389 Share on other sites More sharing options...
litebearer Posted January 7, 2011 Share Posted January 7, 2011 Psuedo code top of page if submited $var = query results else $var = default value Quote Link to comment https://forums.phpfreaks.com/topic/223719-show-a-certain-quarry-when-page-with-form-first-loaded/#findComment-1156404 Share on other sites More sharing options...
QuickOldCar Posted January 7, 2011 Share Posted January 7, 2011 Yeah is bunch of ways. See which works best for you. if (!$_GET['value']) { $value = "value"; } if (!isset($_GET['value']) or $_GET['value'] == '') { $value = "value"; } if (empty($_GET['value'])) { $value = "value"; } if (empty($_SERVER["QUERY_STRING"])){ $value = "value"; } Quote Link to comment https://forums.phpfreaks.com/topic/223719-show-a-certain-quarry-when-page-with-form-first-loaded/#findComment-1156407 Share on other sites More sharing options...
comparebest Posted January 8, 2011 Author Share Posted January 8, 2011 thx, QuickOldCar! $_GET['value'] == '' did the trick Quote Link to comment https://forums.phpfreaks.com/topic/223719-show-a-certain-quarry-when-page-with-form-first-loaded/#findComment-1156513 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.