Jump to content

Dathremar

Members
  • Posts

    169
  • Joined

  • Last visited

Everything posted by Dathremar

  1. If You can't change the table, I really am out of ideas how to order them by the % of the match. Maybe try out makeing different query for every search word entered and then count the words that matches and make a display of results by that, but imo that will be a lot of queries and not sure that is a good way to accomplish this. Better try googling for similar search scripts that can help You. Good luck
  2. You need to add the order at the end of the query
  3. Dunno how deep are You in this project, but dividing the name field into something like manufacturer + model number will help here i guess. But even then I am not sure how are You going to order them by model cuz of simple reason You won't know which of the search words are the model number... Other idea: 1.Make a search with LIKE with all the search word by manufacturer 2. If a match is found, eliminate it from the search 3. Make a search string and search a match by the model with the other words 4. Display 1st the results from the 2nd query then from the 1st query. Another thought: Make UNION something like: qry1="(select *, ordered 2 from product_table where ("; qry2=" UNION (select *, ordered 1 from product_table where ("; $nb_parts = count($search_parts); for ($i = 0; $i < $nb_parts; $i++) { $qry1 .= " ( manufacturer LIKE '%". $search_parts[$i] ."%') "; $qry2 .= " ( model_nb LIKE '%". $search_parts[$i] ."%') "; if ($i == $nb_parts-1) { $qry1 .= ") "; $qry2 .= ") "; } else { $qry1 .= " OR "; $qry2 .= " OR "; } } $main_query = $qry1 . $qry2 . " ORDER BY ordered ";
  4. Hmm i am not that good with MySql :/ Adding a sorting of some kind would help here, but not sure what to sort them by. Can You tell me more info about the table structure please?
  5. Not sure if this is the best way but You could try: $search_parts = explode(" ", $search_text); $qry="select * from product_table where ("; $nb_parts = count($search_parts); for ($i = 0; $i < $nb_parts; $i++) { $qry .= " ( product_name LIKE '%". $search_parts[$i] ."%') "; if ($i == $nb_parts-1) $qry .= ")"; else $qry .= " OR "; }
  6. Maybe try to put that variable into a session and use it while You need it and then destroy it. Just a thought
  7. <form method="post" id="contactForm" action="file_to_do_action"> Think You should add action on Your form
  8. $q = "SELECT name_id, firstname, lastname FROM personal where firstname LIKE '%".$text."%'"; But I recommend to check $_POST['search'] if it contains the desired information, before You use it in the query.
  9. <?php $con = mysql_connect("localhost","xxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,15"); echo "<table border='0'> <tr> <th>Latest News</th> </tr>"; while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<tr>"; echo "<td><h2><a href='$url'>".stripslashes($row['article_title'])."</h2></a>"; echo "<p>{$row['article_teaser']}</p></td>"; } mysql_close($con); ?> You trying it like this?
  10. Use stripslashes($row['article_title')? Stripslashes function php.
  11. SELECT * from table WHERE thedate > todays date will give You the dates that are larger then today's date. Do you have that kind of record? Maybe try: SELECT * from table WHERE thedate >= todays date; And try printing out "thedate" to see if the format matches
  12. Hmm If i get You right $percentage = 25; // Put here the random number for dynamic percentage $act1c = 0; $act2c = 0; for ($i = 1; $i <= $percentage; $i++){ $action = $action1; $act1c++; } for ($j = $percentage; $j <= 100; $j++){ $action = $action2; $act2c++; } Is this better or I am still missing the point :S
  13. $percentage = rand( 0, 100); That will be a random number between 1 and 100. And if You want that percentage to be changing according to some rules or conditions then tell us what.
  14. Before You do the insert into database do a check if the username already exists, something like: "SELECT table_id FROM users WHERE username = '$your_input_var'" If this statement returns number of rows > 0 then print out "Sorry this username has already been taken" Hope this helps
  15. The problem with: $this->uploadLocation = $_SERVER['DOCUMENT_ROOT'] . "static/gallery/products/" . $_GET['id']; is the missing "/" in the path. Like ToonMariner said he is not sure if $_SERVER['DOCUMENT_ROOT'] has "/" or not
  16. I suggest You echo out the location and see if it matches You requirements. That would help You find whats missing in the path
  17. What anupamsaha said or try using AJAX. If you are expecting some kind of response to the post method
  18. Put id on that <li> tags and then use Java Script to put the "active" class on your selected link. For the java script part: document.getelementbyid(id_changed).className = newClass; document.getelementbyid(id_previous).className = ""; // or some other class Also another option is if You reload the page do that with php.
  19. <?php //Get DB configuraion file require('./config/config.php'); //Set variables $species = $_POST['species']; $location = $_POST['location']; $state = $_POST['state']; $date = $_POST['date']; $comments = $_POST['comments']; if (isset($_FILES['image']['tmp_name'])) { //Check file is a valid image and under 200kb if (($_FILES["image"]["type"] == "image/jpeg") && ($_FILES["image"]["size"] < 200000)) { //prepare the image for insertion $image =addslashes (file_get_contents($_FILES['image']['tmp_name'])); } else echo "Sorry, your image is more then 200KB or you have entered an invalid file type (.jpg only)"; } else $image = 'NULL'; //Insert into database $sql="INSERT INTO bird_db (image, species, location, state, date, latlong, comments) VALUES ('$image', '$species', '$location', '$state', '$date', '$latlong', '$comments')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else echo "Thank you, your record has been added to the database"; } ?> Try this. P.S Not tested for errors
  20. You can do this by "preloading" the values into javascript arrays and then make onChang function to modify the 2nd select or try using AJAX so when You select something from the 1st select You will populate the 2nd select with new values.
  21. $query_one = "SELECT strapline from cfm_seo WHERE site_id = '".SITEID."' AND section_id = '".$subSecID."'"; Try this. I put single quotes around the variables
  22. Create a php file with this code: <? phpinfo(); ?> And then open it in a browser and search for CURL.
  23. curl is a library that needs to be included into PhP. Check Your php.ini if the libratry is included
  24. query = "INSERT INTO gastboek (naam, bericht, datum) VALUES ('" . $naam . "', '".$bericht."', '" . $datum . "');";
  25. But to be honest I would just use explode function. Something like this: function getExtension($str) { $parts_string = explode( ".", $str ) if (count($parts_string) > 1) return $parts_string[1]; else return ""; }
×
×
  • 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.