suess0r Posted December 19, 2006 Share Posted December 19, 2006 OK,i have pg1.php which has 3 dropdowns they can choose from with a button 'submit.' I have all of my queries running smoothly and correctly, i'm just having the following problems...1. If they don't select anything and hit submit, it takes them to pg2.php - instead of displaying a message saying "Please select from atleast one of the following options" and not leaving the page.2. If they do choose something and it runs the query and doesn't find anything, it doesn't say "Search Results not found..." ---i tried doing this if outside of my for loop[quote]if (mysql_num_rows > 0) { for ($i = 0; $i < mysql_num_rows($result_set); $i++) { -queries-}} else {echo 'Search Results not found...';[/quote]*but unfortunately this kept returning Search Results not found... no matter what.*hopefully someone can shed some light on these minor 2 problems. thanks!! -Someone had suggested something like this, but I'm POSTing the variables to a second page, so there's no way for me to check if isset() without going to the other page is there??-[quote]<?php$errMsg = "";//get infor from dropdownif(!empty($_POST['mydropdown'])) { $value1 = $_POST['mydropdown];} else { $errMsg .= "You forgot to select an option";}if($errMsg == "") { // No errors continue to page 2} else { // There were errors display them: echo $errMsg;}?>[/quote] Link to comment https://forums.phpfreaks.com/topic/31192-setting-a-blank-form-flag-and-if-results-are-not-found/ Share on other sites More sharing options...
michaellunsford Posted December 19, 2006 Share Posted December 19, 2006 first problem... don't you have to use a result code with mysql_num_rows? like mysql_num_rows($result) ???The second problem would javascript form validation -- I'll dig on the site and post a tutorial if I find one.[b]here we go[/b] http://www.phpfreaks.com/quickcode/JavaScript-Simple-Form-Validation-Script/276.php Link to comment https://forums.phpfreaks.com/topic/31192-setting-a-blank-form-flag-and-if-results-are-not-found/#findComment-144198 Share on other sites More sharing options...
suess0r Posted December 19, 2006 Author Share Posted December 19, 2006 OK, i do use a result code in my for loop and i have no problem running a query to get my results... it's just when there is no results i want to say "Sorry, no results found.." instead of just being an empty table. thanks for the help Link to comment https://forums.phpfreaks.com/topic/31192-setting-a-blank-form-flag-and-if-results-are-not-found/#findComment-144205 Share on other sites More sharing options...
michaellunsford Posted December 19, 2006 Share Posted December 19, 2006 [quote]if (mysql_num_rows > 0) { for ($i = 0; $i < mysql_num_rows($result_set); $i++) { -queries-}} else {echo 'Search Results not found...';[/quote]You've got the gist of it, but the first line of code there doesn't specify a result -- I'm thinking it will be permanently false (in fact I'm surprised there isn't a parse error). Link to comment https://forums.phpfreaks.com/topic/31192-setting-a-blank-form-flag-and-if-results-are-not-found/#findComment-144211 Share on other sites More sharing options...
suess0r Posted December 19, 2006 Author Share Posted December 19, 2006 how silly of me i forgot that mysql_num_rows() was a function ;x and i passed $result_set and it worked perfect, thanks for the help michael! :D Link to comment https://forums.phpfreaks.com/topic/31192-setting-a-blank-form-flag-and-if-results-are-not-found/#findComment-144268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.