Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. Due to some goofy code in a script my clients are using I have to create multiple category fields in the database instead of one category field. So, to do a search I have this query: $sql = "SELECT * FROM amember_members WHERE is_lender='0' AND category1='$category' OR category2='$category' OR category3='$category' OR category4=''$category' OR category5='$category' AND loan_type='$loantype' AND loan_amount='$loanamount' ORDER BY top_3 LIMIT 10"; Basically all the OR statements are checking against the same $category variable to see if they match. I was wondering if there's a shorter way to write the OR statement, perhaps consolidate them... ?
  2. Have you tried to code this yourself yet? If so, post your code. That's the normal start here. Otherwise they might as well rename the site 'Request A PHP Script.com'. Get the idea? We're all willing to help. But not willing to produce 100% of what you need.
  3. This is where you have to be careful with your quotation marks. As long as you use single quotes on the href= content then the two //'s won't be considered PHP comment starters. Normal: <a href="http://www.yoursite.com">Your Site</a> When wrapped in PHP code: <a href='http://www.yoursite.com'>Your Site</a>
  4. redarrow's snippet will fix your problem. But just a bit of FYI on this so you understand. 1. you can have multiple $row[''] variables in any line if formatted properly 2. in your <a href= you either have to use just the page name like redarrow shows or the full URL including the http:// part. Since you used just the www. it automatically places your full url again in front of that which was causing the double address. Hope this helps for the future
  5. Thanks. The missing ' fixed the issue. I think I need a break and some coffee
  6. Thanks, Thorpe. Only question now is why does it only display Cat2 and Cat3 in the dropdown? In viewing page source it shows all 3 category options. But, in the display of the actual dropdown only those two are in the select box. http://www.lenderfish.com/search-test.php
  7. I've created this simple function that when called should generate a drop down select form element. However, it's not cooperating! <?php function search_form() { // do sql query for data $sql = "SELECT category FROM categories"; $results = mysql_query($sql) or die(mysql_error()); $info = mysql_fetch_array($results); // echo essential HTML to start form echo "<form method='POST' action='search.php'> <select name='category>"; // now loop through the query results to create selections foreach($info as $month) { echo "<option value='$month' name='$month'>$month</option>\n\r"; } echo "</select>"; echo "<input type='submit' name='search' value='Search'>\n </form>"; } ?> It's not displaying all the category names in the list, just the first one. There's three: Test Cat1 Test Cat2 Test Cat3 All that displays is Test Cat1. The foreach loop should create a new <option> for each one in the array. But it's not.
  8. ding! ding! ding! Barand wins the gold monkey! I have NOT tried it...yet! I guess I figured I could 'solve' any issues before banging my head against the wall for an hour or two. I will give 'er a rip and report back
  9. First, as always, thanks for the posts! Ok, the 0's should be on top. I guess what I thought would happen is the 0's would display and then nothing else after the 0's ran out. Simple logic running through my simple mind. display 0's 1's don't display cuz they ain't 0's So, if i'm getting the jist of your comments, it will display ALL the results but just prioritize to the 0's then when those run out displays the 1's automatically.
  10. I'm creating a directory of nationwide lenders of which can elect to be shown in the Top 3 of the results for their category. I have a field in the 'members' table for top_3 with the value being either 1 for no or 0 for yes, that they are not in/in the top 3. So, what I want to do is in my query for displaying the results of the search is place a priority on those that qualify, show them in the top 3..then the remainder below that. This would be similar to the 'sponsored' links you see in many directories. I just have a snippet of the query as a starter: <?php $sql = "SELECT * FROM amember_members WHERE is_lender='0' AND category='$category' AND loan_type='$loantype' AND loan_amount='$loanamount' ORDER BY top_3"; ?> So, the query should pull all results matching certain criteria (loan amount, loan type, etc.) THEN prioritize the display IF the lender is designated in the top 3. I searched around for something on this but couldn't find anything specific.
  11. Another way to do this is to NOT put your HTML in the database. Instead, place the HTML in the echo area of your PHP and simply call the field with the text into the spot in your HTML you'd like to have it placed. Example: <?php $sql = "SELECT * FROM table_name"; (just an example query, not meant to be actual) $results = mysql_query($sql) or die(mysql_error()); echo"<ul>"; while($row = mysql_fetch_array($results) { echo" <li>" . $row['field_name'] . "</li>"; } echo "</ul>\n";
  12. Ok, thanks! Found the problem with a table spelled incorrectly being summoned in the query
  13. I have this function including the query: function getTopRated($limit, $table, $idfield, $namefield){ $result = ''; $sql = "SELECT ratings.rating_id,".$table.".".$namefield." as thenamefield,ROUND(AVG(ratings.rating_num),2) as rating FROM ratings,".$table." WHERE ".$table.".".$idfield." = ratings.rating_id GROUP BY rating_id ORDER BY rating DESC LIMIT ".$limit.""; $sel = mysql_query($sql); $result .= '<ul class="topRatedList">'."\n"; while($data = mysql_fetch_assoc($sel)){ $result .= '<li>'.$data['thenamefield'].' ('.$data['rating'].')</li>'."\n"; } $result .= '</ul>'."\n"; return $result; } Returning this error on line 187 which is the 'while($data = mysql_fetch_assoc($sel))' statement:
  14. That god rid of the php error, but the image upload is producing errors: # The file type you have attempted to upload is not the proper format. Only .jpg or .gif files are allowed. # Something went wrong with the upload. Please try again. Even though i've tried both .gif and .jpg neither uploads. BUT, if I try uploading a .doc file it does upload but still throws the error that only .gif or .jpg files can be uploaded. Totally confused.
  15. I'm doing a simple file upload with some modest validation parameters. I thought I had this down but I get this error message when using this code: // let's do some validation for file type if(isset($_POST['submitted'])){ $file_type = array(gif, jpg); $file_upload = $_FILES['uploadedfile']['type']; $max_size = "100000"; // create an error message array $errors = array(); if(!in_array($file_type)) { $errors[] = "The file type you have attempted to upload is not the proper format. Only .jpg or .gif files are allowed."; exit; } if($_FILES['uploadedfile']['size'] > $max_size) { $errors[] = "The file size is too large. Reduce the number of bytes below $max_size and try again"; exit; } else { $target_path = "images/clients/"; // add target path and file name $target_path = $target_path . basename($_FILES['uploadedfile']['name']); // get temporary name $temp_name = $_FILES['uploadedfile']['temp_name']; // let's move the file to permanent home if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br>"; } else { $errors[] = "Something went wrong with the upload. Please try again.<br> "; } // end of else statement } // end of if submitted statement } ?> Error message is: Wrong parameter count for in_array()
  16. Just want to request one more time... anyone have experience with converting Word docs to PDF files using PHP?
  17. Post your code, please, so we can have a peek.
  18. Actually you don't need to create two tables. If it's a staff directory just put all their info into one.
  19. I don't have a specific question or code problem..yet. First I'm looking for input into the availability of class files or code snippets that can handle the upload and conversion of Word docs to PDF format. I didn't see anything in the resources here or tutorials. Looking at PHP.net there's functions pertaining to PDF files but, again, looking for actual real world application of same. Anyone?
  20. Just use an iframe and summon that url into it.
  21. It's not that it wouldn't work...it's just that you'd be giving up other functions that might be useful like searches, keywords, etc.
  22. It could only be Ajax...which is hybrid Javascript. PHP requires the page to refresh in order for anything to happen. The fact it checked without any other action other than entering the data and mousing away indicates it's Ajax which doesn't require a page refresh to execute its actions.
  23. It would be helpful if we knew the actual error. Replace this code: $insert = mysql_query("insert into replays (type, title, filename, author, map, date_time) VALUES ('$type','$title','$target_path','$username','$map','$date')"); with this: $insert = mysql_query("insert into replays (type, title, filename, author, map, date_time) VALUES ('$type','$title','$target_path','$username','$map','$date')") or die(mysql_error());
  24. There's a forum specifically for Oracle and PHP. The Mods will probably move this over there
×
×
  • 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.