Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. Ken2k7... me either...lol! This one is a stumper. If the query fails it should meet the condition of the if/else and display the else content. Regarding your question, actually you can't select just one. The javascript validation prohibits the first item listed from being a selection (thanks to the javascript forum guys). It requires two selections to make it work. Gentlemen, I have to get some sleep. Gotta get up in less than 5 hours. Perhaps my rested eyes can spot the problem tomorrow. Thanks again for your posts. Let's tackle it in the morning!
  2. redarrow, i'm using your code right now. Your latest post. Go to: http://www.lenderfish.com/search-test.php select Purchase in the 1st box and Rate and Term Refinance in the other. You'll see that there's results for that. Go back to the search page and in just the second box select Stated while leaving the first box the same. There's no match for that. See what happens.
  3. lol... dude, BELIEVE ME.. i'm totally appreciative of your help. Now, just tried the latest version. STILL fails when one of the search criteria isn't met. I've been scratching my head on this till it bleeds. Ok, more info: What i'm doing is omitting the 'Stated' loan_type from a member's profile. Then, i'm searching for that loan type in the 2nd drop down along with a category in the first drop down that I know is listed in his profile. IF I select both criteria knowing full well that they ARE in his profile then the results display fine. SO...the way the query is written is 'AND' this 'AND' that so that it should meet both requirements in order to display in the results. IF both conditions aren't met (along with the 'is_lender' condition which specifies that their membership status as a lender) then it should display ' Sorry but there's no results '. IF both conditions are met then it should display the results. It's so simple in concept but I can't figure out why it won't work. IF $results DISPLAY $results.. IF NO $results DISPLAY this -> message Ken2K7, the query works as is. What's not happening is the display of the 'else' content IF the search doesn't produce results. I don't think the single quotes would make a diff since the query is working without errors. Something is either breaking OR it's possible.... possible... that the reason the page is totally blank is because either PHP or MySQL is timing out on the query for some reason which is causing the script to die.
  4. I'll try it..but wouldn't the absence of the 'while' loop limit me to one result? There would most likely be up to 10 lenders that would match the criteria for each category. Let me give this a shot. Be right back. Ok, gave it a whirl. Now, no matter what I select, it displays the 'No results match...' content. So, what's happening with this version is no results are being pulled.
  5. Well, perhaps I should explain. The dropdowns are populated from separate tables that are totally separate from the data for the results. The $category and $loantype variables are populated by the form that holds the two dropdowns. The data containing the content for the results is in a table called 'amember_members' as it's looking through the member's data to see what matches. Now, the data is much more complex. There's not a single 'category' field. There's 5. (category_1, _2, etc.) and there's 5 different loan_type fields (_1, _2,_3,_4, _5). So, the idea is to match their two selections from the dropdown with the various fields in the data. When it's done it should display the results. If there aren't any that match the criteria then it should display the 'else' content. Unfortunately it's not.
  6. Ken2K7, basically they're set up like your example. Two separate tables containing the items as shown in those dropdowns respectively. The two drop downs are populating perfectly with the selections. redarrow, tried it and still produces a blank page when using the 'fail' search. Also, produces a slew of errors such as: Notice: Undefined variable: row in /home2/wwwfish/public_html/search.php on line 35 Notice: Undefined variable: row in /home2/wwwfish/public_html/search.php on line 36 Notice: Undefined variable: row in /home2/wwwfish/public_html/search.php on line 37 Notice: Undefined variable: row in /home2/wwwfish/public_html/search.php on line 38 Company phone: Company contact: Submit Loan Request Notice: Undefined variable: row in /home2/wwwfish/public_html/search.php on line 41
  7. Here's the whole setup: <?php ini_set("display_errors", 1); error_reporting(E_ALL); ini_set("display_startup_errors", 1); include 'db_config.php'; /** * @author rockmetal * @copyright 2007 */ // query for extracting lenders from amember database $category = strip_tags(trim($_POST['category'])); $loantype = strip_tags(trim($_POST['loan_type'])); //$loanamount = strip_tags(trim($_POST['loan_size'])); $sql = "SELECT * FROM amember_members WHERE is_lender='Yes' AND '$category' IN (category_1, category_2, category_3, category_4, category_5) AND '$loantype' IN (loan_type, loan_type2, loan_type3, loan_type4, loan_type5) ORDER BY top_3 LIMIT 10"; $results = mysql_query($sql) or die(mysql_error()); $numrows = mysql_num_rows($results) or die(mysql_error()); if (mysql_num_rows($results) === 0){ include 'header.php'; echo "<h3>No Results Found</h3><br> <p class='bodytext'>No lenders matched your search criteria. Try modifying the search parameters for broader results.<br>\n"; echo "<br><input type=button value=\"Return to Search\" onClick=\"history.go(-1)\">"; include 'footer.php'; } else { include 'header.php'; echo "<h3>The following lenders meet your search criteria.</h3><br>\n"; // create display of results in abbreviated format while ($row = mysql_fetch_array($results)) { echo " <div class='wrapper_out' onmouseover=\"this.className='wrapper'\"; onmouseout=\"this.className='wrapper_out'\";> <table width='500' border='0' align='center'> <tr ><td colspan='2' class='lendertitle'>".$row['company_name']."</td></tr> <tr><td colspan='2' class='lenderdesc'>Company phone: ".$row['company_phone']."</td></tr> <tr><td width='300' class='lenderdesc'>Company contact: ".$row['company_contact']."</td> <td width='200'><a class='lenderlink' href='loanrequest.php?lenderid=".$row['member_id']."'>Submit Loan Request</a></td></tr> <tr><td colspan='2'>"; echo pullRating($row['member_id'],true,false,true); echo "</td></tr> </table></div><br />\n"; echo "<hr style='border-top: 1px dotted #666666' color='#666666' width='400' size='1'>"; } include 'footer.php'; } ?> redarrow, I did try that if(!$results) { method and got the same thing. That's what's puzzling. Ken2k7, the tables are set up fine. If you search for something you know is there then the results display perfectly. It's only when one of the conditions isn't met. In this case, as in the example I gave, if you choose Stated then whatever in the second drop down then the query should be empty and the IF condition should be met and HTML displayed. Not doing that.
  8. Hmmm... still producing a blank page. I've tried SOOO many combos and methods. Right now here's what I have: $sql = "SELECT * FROM amember_members WHERE is_lender='Yes' AND '$category' IN (category_1, category_2, category_3, category_4, category_5) AND '$loantype' IN (loan_type, loan_type2, loan_type3, loan_type4, loan_type5) ORDER BY top_3 LIMIT 10"; $results = mysql_query($sql) or die(mysql_error()); $numrows = mysql_num_rows($results) or die(mysql_error()); if (mysql_num_rows($results) === 0){ include 'header.php'; echo "<h3>No Results Found</h3><br> <p class='bodytext'>No lenders matched your search criteria. Try modifying the search parameters for broader results.<br>\n"; echo "<br><input type=button value=\"Return to Search\" onClick=\"history.go(-1)\">"; include 'footer.php'; } else { If you go to: http://www.lenderfish.com/search-test.php select 'Stated' in the first drop down and anything in the next and you'll see what happens. Might help. Basically there are no results from the database for anything in the query related to Stated so it should produce the IF condition if that's the case. But it's not.
  9. I'm running this query whereas IF there's no results then it should display an alternative message. However, when there's no results it just shows a blank page entirely...which means it's breaking somewhere but I can't see why it's not functioning properly. If I select in the search the two elements that I know produce results then it displays fine. It's only when there's no results that it breaks. // query for extracting lenders from amember database $category = strip_tags(trim($_POST['category'])); $loantype = strip_tags(trim($_POST['loan_type'])); //$loanamount = strip_tags(trim($_POST['loan_size'])); $sql = "SELECT * FROM amember_members WHERE is_lender='Yes' AND '$category' IN (category_1, category_2, category_3, category_4, category_5) AND '$loantype' IN (loan_type, loan_type2, loan_type3, loan_type4, loan_type5) ORDER BY top_3 LIMIT 10"; $results = mysql_query($sql) or die(mysql_error()); $numrows = mysql_num_rows($results) or die(mysql_error()); if(empty($results )){ include 'header.php'; echo "<h3>No Results Found</h3><br> <p class='bodytext'>No lenders matched your search criteria. Try modifying the search parameters for broader results.<br>\n"; echo "<br><input type=button value=\"Return to Search\" onClick=\"history.go(-1)\">"; include 'footer.php'; } else {
  10. Bing-goooo! Works like a charm...you Javascript guys rock!
  11. Ummm, what you really need is a hefty dose of Ajax to create sortable tables. Google it and you'll find a few good scripts and resources for it.
  12. Actually, to clarify, what i'd like is for them to not be able to either accidentally OR on purpose try to submit the form without first making a selection. Since the 'default' is Select One and they should try to submit without first selecting an item it should stop them in their tracks. More like: You must select a category prior to submitting the form! So, realistically it should work both ways. 1) IF they try to submit the form without first selecting an item from each menu, OR 2) IF they try to select the Select One as their selection and attempt to submit Heh, I should probably do myself a favor and just omit those Select One placeholders But, the purpose is to make sure they make the two necessary selections in order for the search to work properly. Make sense?
  13. First, thanks for the post! Ok, I inserted your code as follows. The <script> items into the <head> tag and the other like so: function search_form2() { echo "<form method='POST' action='search.php'><select id='cat' name='category' onchange='opt(this.value)'>\r"; echo "<option selected value='ignore'>Select One</option>"; $sql = "SELECT category FROM categories"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<option value='{$row['category']}' name='{$row['category']}'>{$row['category']}</option>\n\r"; } } } echo "</select>\n\r"; Now, when I leave the selection at Select One and the other drop down to whatever, the search still takes place. In other words it's not stopping the search from proceeding. As a result the search is breaking which displays a blank page. You can see what I have here: http://www.lenderfish.com/search-test.php There's two drop downs. I'll need to adapt the final code to the second one as well.
  14. This is a PHP/Javascript form field validation issue so thought i'd post here. I have a drop down menu that is created dynamically via PHP/MySQL. The first selection, however, is static and is basically --Select One-- or similar. I do not want them to ignore selecting so it needs to be made so it can't be selected and alert them. I haven't a clue since i'm more PHP than Javascript oriented. Here's my code for the menu: function search_form2() { echo "<form method='POST' action='search.php'><select name='category'>\r"; echo "<option>-- Select Category --</option>"; $sql = "SELECT category FROM categories"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<option value='{$row['category']}' name='{$row['category']}'>{$row['category']}</option>\n\r"; } } } echo "</select>\n\r"; // property type form echo "<select name='loan_type'>\r"; $sql2 = "SELECT loantype FROM loan_type"; if ($results2 = mysql_query($sql2)) { if (mysql_num_rows($results2)) { while($row2 = mysql_fetch_assoc($results2)) { echo "<option value='{$row2['loantype']}' name='{$row2['loantype']}'>{$row2['loantype']} </option>\n\r"; } } } echo "</select>"; echo "<input type='submit' name='search' value='Search'>\n</form>"; } Somehow I need to 'validate' or 'disable' this choice: echo "<option>-- Select Category --</option>"; Anyone? Thanks in advance!
  15. I don't think this part works in your 'if' statement since I don't see where you're checking the value of $moderator: <? if ($moderator > 1) { if ($ip) { $lijstgebruikers = "SELECT * FROM ip_logs WHERE ip='$ip' ORDER BY id DESC"; } else { $lijstGebruikers = "SELECT * FROM ip_logs ORDER BY id DESC"; } -> /*LINE 37!!*/ $resultLijstGebruikers = mysql_query($lijstGebruikers); while ($row = mysql_fetch_array($resultLijstGebruikers)) { echo "<tr><td><a href=\"viewprofile.php?viewprofile=$row[username]\">$row[username]</a></td><td>$row[when]</td><td><a class=\"menuItem\" href=\"adminban.php?ip=$row[ip]\"><font color=green>$row[ip]</font></a></td></tr>"; } } else { echo "<b>Denne siden har du ikke tilgang til!</b>"; } ?> But, if it is and we just don't see it, then the first query would return true but your 'while' statement references the second one. Note the lowercase 'g' instead of the uppercase 'G' in the two queries.
  16. In your mysql query use the ORDER BY to sort it by date and the LIMIT so it shows just the 3.
  17. Exactly, if you echo the $borid2 it will just display your query, not the results. $results = mysql_query($borid2) or die(mysql_error()); if($results){ echo $results; } else { echo "There are no results! Help!"; }
  18. Don't think he needs that second = sign. Also, be sure that the $productid variable has a value.
  19. Or, I could do it like this where I separate the echo statement: echo "<h3>The following lenders meet your search criteria.</h3><br>\n"; // create display of results in abbreviated format while ($row = mysql_fetch_array($results)) { echo "<table width='550' border='0'> <tr colspan='2'><td class='lendertitle'>".$row['company_name']."</td></tr> <tr><td class='lenderdesc'>Company phone: ".$row['company_phone']."</td></tr> <tr><td>Company contact: ".$row['company_contact']."</td><td><a class='lenderlink' href='loanrequest.php?lenderid=".$row['member_id'].">Submit Loan Request</a></td></tr><tr><td>"; echo pullRating(35,false,false,false,NULL); echo "</td></tr></table><br />\n "; }
  20. Ok, i'll see if I can clarify. The results of the query are displayed in HTML via echo. In that block of HTML code I have a 5 star rating system i'd like to include in there that, in itself, uses an 'include' statement to call it (the one I posted in previous response). However, that include statement also includes the <? ?> tags and an additional 'echo' statement. Assuming I don't need either of those since that entire block is already being echoed, what changes would I make to that tag in order for it to summon in that location? Make sense? This may help. It's the instructions from their download:
  21. Whatever it is I can't find it in any of the tutorials or references I have. Here's a list of the operators: http://www.htmlgoodies.com/beyond/php/article.php/3472471
  22. Ok, that's what was breaking it. The rating include. Actually it's supposed to be there but I didn't modify the code to correct syntax. Here's the recommended 'tag' they suggest using. However, this is including additional PHP echo commands that I don't need since it will be inserted into a block of HTML that is already being echoed. <? echo pullRating(35,false,false,false,NULL); ?> So, say I wanted to place this where the include('star_rating') code is now. How/what would I modify to make this work? I've tried a few combos but my PHP editor reports errors.
  23. Here's the code for the query: <?php include 'db_config.php'; /** * @author rockmetal * @copyright 2007 */ // query for extracting lenders from amember database $category = strip_tags(trim($_POST['category'])); $loantype = strip_tags(trim($_POST['loan_type'])); $loanamount = strip_tags(trim($_POST['loan_size'])); $sql = "SELECT * FROM amember_members WHERE is_lender='Yes' AND '$category' IN (category_1, category_2, category_3, category_4, category_5) AND loan_type='$loantype' AND loan_size='$loanamount' ORDER BY top_3 LIMIT 10"; $results = mysql_query($sql) or die(mysql_error()); $numrows = mysql_num_rows($results) or die(mysql_error()); if($numrows == 0){ echo "<h3>No Results Found</h3><br> <p class='bodytext'>No lenders matched your search criteria. Try modifying the search parameters for broader results.<br>\n"; } else { // create display of results in abbreviated format while ($row = mysql_fetch_array($results)) { echo "<table width='550' border='0'> <tr colspan='2'><td class='lendertitle'>".$row['company_name']."</td></tr> <tr><td class='lenderdesc'>".$row['company_desc']."</td></tr> <tr><td>Rating:". include('star_rating')."</td><td><a class='lenderlink' href='loanrequest.php?lenderid=".$row['member_id'].">Full Details</a></td></tr> </table><br />\n "; } } ?> The database DOES contain at least one record that would meet the requirements of the query. However, nothing displays. Furthermore, if there were no results then it should display the message to that affect. Instead the page is completely blank when the search is performed. Scratching my head ???
  24. Thanks. I can't find any syntax examples as the mysql site. Can you provide a snippet of the syntax structure for using the IN clause?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.