Jump to content

paulmo

Members
  • Posts

    138
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

paulmo's Achievements

Member

Member (2/5)

0

Reputation

  1. thanks Keith! helps to see how a guru would do it. I'll have to study your arsort () more closely.
  2. after some consideration i'm pretty sure i'll do this with mysql. this is getting closer but it's only returning user text submit words, not the top 15 words in column 'message', which is what I want. mysql_query("INSERT INTO user (name, message, created) VALUES ('$name', '$message', NOW()) ") or die(mysql_error()); $archive = mysql_query("SELECT CONCAT(message, ' ', COUNT(*)) FROM `user` GROUP BY message ORDER BY COUNT(*) DESC LIMIT 15") or die (mysql_error()); $n=0; while($row = mysql_fetch_assoc($archive)){ $n++; echo ($row['message']); echo "<br>"; }
  3. thanks for the suggestion; please help fine tune. still not working. i'm sure i'm supposed to do something with new $where variable--just don't know what. $wordchunks = explode(" ", $message); $where = "(message LIKE '%" . implode("%' OR message LIKE '%", $wordchunks) . "%')"; for($i = 0; $i < count($wordchunks); $i++){ echo "Word: $i = $wordchunks[$i] <br />"; } //$message = preg_split("/[\s,]+/")($message); foreach ($wordchunks as $word) { $word = trim($word); $skip = false; } if arrays follow...
  4. I've tried with and without pre_filter(trim). Still, only last word of string is being searched, whereas I need EVERY word searched. Thanks again in advance. $message = strip_tags($message); $message = mysql_real_escape_string($message); //$pre_filter=trim($message); $wordchunks = explode(" ", $message); for($i = 0; $i < count($wordchunks); $i++){ echo "Word: $i = $wordchunks[$i] <br />"; } //$message = preg_split("/[\s,]+/")($message); foreach ($wordchunks as $word) { $word = trim($word); $skip = false; }
  5. I've got several "if/elseif" arrays that follow the code below, where message ($word) comes from submitted text form that contains sentences with ANY words. problem is, only the LAST word in message is being searched against my if/elseif arrays. I need EVERY word from message searched. so my $word variable isn't right. my //comments are here to show different things I've played with. $message = $_POST['message']; $post_message = ucfirst($message); $message = mysql_real_escape_string($message); $message = strip_tags($message); //$message = trim ($message); $pre_filter=trim($message); $get_search=explode(" ",$pre_filter); //$post_message = stripslashes($post_message); //$where = ''; foreach ($get_search as $word) { $word = trim($word); // $skip = false; use this later }
  6. first I'm inserting in table (this works): mysql_query("INSERT INTO user (name, message, created) VALUES ('$name', '$message', NOW()) ") or die(mysql_error()); next I need to retrieve (limit) the top 15 words in message column, user table, sorted vertically with occurrence # beside the word, like: sea 23 tree 12 leaf 3 etc. I've started this but I need help. $archive = mysql_query("SELECT * FROM user ORDER BY message") or die (mysql_error()); $results = mysql_query($archive);
  7. not sure how "dumb" figures but yes I'm looking at boolean true or falses for each column now.
  8. like this: On one table, $word (which is a text string from form) gets matched to column 'good'; if match, $word gets matched to column 'keyword'; match on 'keyword' echoes same row id in 'echo_good' column to user. if no match on 'good', match against column 'bad' etc. if no match on good or bad but match on 'keyword', echo message to user to elaborate on keyword match.
  9. Someone who is good at queries please respond on this one. Thanks
  10. you're right that the query is probably the problem but I didn't define that in this post; that's here http://www.phpfreaks.com/forums/index.php/topic,281766.0.html if you would please give it a shot. $word in this thread is just the user submitted text--it's random and doesn't make exceptions as to order. maybe I was unclear. the string variable $word is probably ok afterall though and the query is the problem.
  11. $word variable is only getting searched on last word in string against db, whereas I need any and [mostly] every word in string searched, in any order. for example "hot water" gets match because 'water' is in db table, but 'water hot' is returning no results. thanks in advance for ideas. $message = mysql_real_escape_string($message); $message = strip_tags($message); $name = trim($name); $name = strip_tags($name); $name = mysql_real_escape_string($name); $pre_filter=trim($message); $get_search=explode(" ",$pre_filter); $post_message = stripslashes($post_message); $name = $_POST['name']; $post_name = ucfirst($name); echo "Message: {$post_message}<p>"; $where = ''; $common = array('they', 'this', 'that', 'them', 'those', 'your',); foreach ($get_search as $word) { $word = trim($word);
  12. I need help getting this query started, either nested loop or join. On one table, $word (which is a text string from form) gets matched to column 'good'; if match, $word gets matched to column 'keyword'; match on 'keyword' echoes same row id in 'echo_good' column to user. if no match on 'good', match against column 'bad' etc. if no match on good or bad but match on 'keyword', echo message to user to elaborate on keyword match. thanks in advance to someone who can get me off the ground on this one.
  13. anyone take a shot at this please?
×
×
  • 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.