Jump to content

djinnov8

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

djinnov8's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I think I found something... http://www.webspeaks.in/2010/05/facebook-style-toggle-comment-box.html It utilises CSS, Jquery, HTML and PHP
  2. Maybe I should've labelled this PHP toggle functionality similar to js toggle script (I've heard that you can break out of php midway through a statement or you could enclose key parts of the javascript script within (brackets) and echo other parts to get it to work within PHP code... This wouldn't work but I hope it lets you know what I'm after... <?php... { while($rows = mysql_fetch_array($result)) { echo $rows['first_name'] . '<br />'; echo $rows['last_name'] . '<br />'; ?> <script language="javascript"> function toggle() { var ele = document.getElementById("toggleText"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; } else { ele.style.display = "block"; text.innerHTML = "hide"; } } </script> <?php echo '<div id='toggleText' style='display: none'>'; echo '<h1>' . $rows['comments'] . '</h1></div>'; echo '<a id='displayText' href='javascript:toggle();'>show</a> <== click Here'; echo '</div>'; } } ...?>
  3. Thanks for the reply...yes - as I mentioned in the post...show and hide the comments of each member similar to the javascript/jquery function.... I've seen this done on countless sites including (to some extent) Facebook...and Im guessing this is the clever use of javascript/jquery and html within the php code...
  4. Hi folks... I have developed a page that contains three percentage sized divs...the left and right contain links whilst the centre contains all the data. Looks great in 1024 x 768 but looks like crap on wider resolutions... I came across some links e.g. http://www.alistapart.com/articles/holygrail/ which were quite ingenious but played havoc with my data and their divs... Any ideas...greatly appreciated [attachment deleted by admin]
  5. Hi everyone... I recently came across some jquery/js code that enables you to (toggle) showand hide a section of html code contained within a div... Now I am trying to do the same thing but with the results of a mysql query contained within PHP... so looking at sample code... $query = "SELECT first_name, last_name, comments from members" $result=mysql_query($query); if(mysql_num_rows($result) < 0) { echo "There are no members"; } else { while($rows = mysql_fetch_array($result)) { echo $rows['first_name'] . '<br />'; echo $rows['last_name'] . '<br />'; echo $rows['comments'] . '<br />'; } } How can I (toggle) show and hide the comments row for each individual member... Thanks for your reply in advance
  6. Found this at ... http://php.tonnikala.org/manual/cs/function.levenshtein.php june05 at tilo-hauke dot de 06-Jun-2005 10:44 //levenshtein for arrays function array_levenshtein($array1,$array2) { $aliases= array_flip(array_values(array_unique(array_merge($array1,$array2)))); if(count($aliases)>255) return -1; $stringA=''; $stringB=''; foreach($array1 as $entry) $stringA.=chr($aliases[$entry]); foreach($array2 as $entry) $stringB.=chr($aliases[$entry]); return levenshtein($stringA,$stringB); } // e.g. use array_levenshtein to detect special expressions in unser-inputs echo array_levenshtein(split(" ", "my name is xxx"), split(" ","my name is levenshtein")); //output: 1
  7. I came across a post that contained something kinda similar... http://stackoverflow.com/questions/1957989/compare-5000-strings-with-php-levenshtein Would Levenshtein do this and if so, I wonder what the syntax would look like?
  8. Hi guys, I am new to PHP/coding and am trying to look for 1. A way of comparing the words in one static array against other dynamically created arrays (created from mysql queries) 2. Work out how many similar words there are - then assign that number to that array My static array is...$comparewithme = array with values = this is an example of an array Mysql_query("select id, words from table_example") Results from query are put into an array that is named according to id.. $result2 = array with values = this is an example of queries $result3 = array with values = this is not an example of php Comparison should give the following info Comparing $comparewithme with $result2 should generate a hit rate of 5 (similar words=this is an example of)... Comparing $comparewithme with $result3 should generate a hit rate of 4 (similar words=this is an example)... Any ideas greatly appreciated...thanks in advance
  9. Thanks Bro - Looks like RWWD was right - use a foreach loop to generate multiple queries going through each of the values in my array and possible combinations of those values... Sheez - that looks like a huge headache for my server...
  10. Oh WT...You spotted my first problem...query is referencing multiple columns...should be... SELECT * FROM recommended_product WHERE product_comment LIKE '%business%' OR product_biz LIKE '%business%';
  11. Hi WT, Trying to pick the out any data in the product_name and product_comment tables that contain any combination of the values in my array... Looking at my example, my query should ask "Does the product_name and product_comment tables have any rows with the word business OR home OR depo... Example 1. So if one of the rows in the product_name table contains a product called like " The business accounting package", then it should pick up that row. Example 2. If one of the rows in the product_name table contains nothing but the product_comment table contains a comment like "I run a business at home"...then my query should pick it up... Example 3. If one of the rows in the product_comment table contains the phrase "I run a business at home called the depo company"...then it should pick this one out as well... Hopefully, I can then use the results and maybe using PHP, choose which query picked out the most words/values from my array...and sort them accordingly. So looking at my examples... Example 3 had three hits from my array Example 2 had two Example 1 had one hit... This means, I will show Example 3 query results at the top because it had the most matches from my array, then query results from Example 2, then Example 1... Hopefully my explanation makes things a little clearer...
  12. Or use implode $query = "SELECT * FROM product WHERE product_name, product_comment IN ('" . implode("','", $query_keywords) . "')"; Thanks for your input Wildteen... I tried your query like this but still ended up with the error... Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in blah\blah\results.php on line 99 no results $query = "SELECT * FROM product WHERE product_name, product_comment IN ('" . implode("' ,'", $query_keywords) . "')"; echo "<br />" . $query; $result=mysql_query($query); if(mysql_num_rows($result) > 0) { echo "results"; } else { echo "no results"; } Here is an echo of my select statement... SELECT * FROM product WHERE product_name, product_comment IN ('business','home','depo')
  13. This forum is the best thing since sliced bread... Thanks RWWD...Yes, I see what you mean so I'll give it a try... I'm a newbie with coding and PHP and have been toying with the foreach loop but on top of the query I need is another problem... I'll probably need to build the foreach loop to query the table for different combinations of the array values... Looking at my array and my table - each column could contain one of my values e.g. 'business' OR... each column could contain two of my values in a different order e.g. "business, depot"...OR "depot, business" ...and so on and so forth depending upon the amount of values I am looking for... I have an idea your foreach loop will do that but my inexperience with coding is complicating matters... If anyone has ideas for the syntax, please let me know...thanks in advance
  14. Hey there... I'm so stuck on this problem I was hoping someone could help... I need to query a MySQL Database using array values... Here is my array ... $query_keywords = Array ( [7] => business [10] => home [11] => depo ) Here is my php ...$query = "SELECT * FROM product WHERE product_name, product_comment IN ($query_keywords)"; $result=mysql_query($query); if(mysql_num_rows($result) > 0) { echo "results"; } else { echo "no results"; } Unfortunately, I get this ... Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in blah\blah\results.php on line 99 Please help me :'( :'( All comments greatly appreciated...
×
×
  • 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.