Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Comparing an Array against a DB

Started 1 month, 2 weeks ago by nawrik
Hi all, all help is greatly appreciated - my head is spinning on this one! Here's the situation... I'm trying to create a photo 'tag' script - think keywords for photos. What I've achieved so far: The user after submitting their 'tags' - punctuation gets stripped and replaced with commas - and all white space is removed: these,are,tags I have then use PHP ...
Site: PHPBuilder.com  PHPBuilder.com - site profile
Forum: Database  Database - forum profile
Total authors: 2 authors
Total thread posts: 7 posts
Thread activity: no new posts during last week
Domain info for: phpbuilder.com

Other posts in this thread:

Weedpacket replied 1 month, 2 weeks ago
Your foreach line has the potential to break something: $tag and $tag is being used to mean two different things at the same time. PHP Code: foreach( $tag as $key => $value ) { $tag [ $key ] = "'" . mysql_real_escape_string ( $value ). "'" ; } $query = "Select tag_name from tags where tag_name in (" . join ( ',' , $tags ). ")"...

nawrik replied 1 month, 2 weeks ago
Weedpacket, thank you for your reply - however it seems to have confused me even more. Even after a sleep, it hasn't clicked. I've started fresh and here is where I am: PHP Code: if (isset( $_POST [ 'submit' ])) { $newtags = htmlentities ( $_POST [ 'tags' ]); // Grab tags created by user $separators = array( "." , ...

Weedpacket replied 1 month, 2 weeks ago
Like I said, collect the returned tag names into their own array: PHP Code: $existing_tags = array(); while ( $currenttags = mysql_fetch_array ( $gettags , MYSQL_ASSOC )) { $existing_tags [] = $currenttags [ 'tag_name' ]; } print_r ( $existing_tags );

Weedpacket replied 1 month, 2 weeks ago
Like I said, collect the returned tag names into their own array: PHP Code: $existing_tags = array(); while ( $currenttags = mysql_fetch_array ( $gettags , MYSQL_ASSOC )) { $existing_tags [] = $currenttags [ 'tag_name' ]; } print_r ( $existing_tags );

nawrik replied 1 month, 2 weeks ago
Fantastic WeedPacket - thank you for your patience. I am now having another problem - I don't understand why...any ideas: This is what i'm using to get the current database of tags. For testing i've print_r the array: PHP Code: $gettags = mysql_query ( "SELECT tag_name FROM tags" ); $currenttags = mysql_fetch_row ( $gettags ); $existing...

nawrik replied 1 month, 2 weeks ago
Sorted. It seems the: PHP Code: mysql_fetch_row was messing with the query - needlessly. Thanks all.

 

Top contributing authors

Name
Posts
nawrik
4
user's latest post:
[RESOLVED] Comparing an Array...
Published (2009-11-09 11:41:00)
Sorted. It seems the: PHP Code: mysql_fetch_row was messing with the query - needlessly. Thanks all.
Weedpacket
3
user's latest post:
Comparing an Array against a DB
Published (2009-11-09 08:12:00)
Like I said, collect the returned tag names into their own array: PHP Code: $existing_tags = array(); while ( $currenttags = mysql_fetch_array ( $gettags , MYSQL_ASSOC )) {      $existing_tags [] = $currenttags [ 'tag_name' ]; } print_r ( $existing_tags );

Related threads on "PHPBuilder.com":

Related threads on other sites:

Thread profile page for "Comparing an Array against a DB" on http://www.phpbuilder.com. This report page is a snippet summary view from a single thread "Comparing an Array against a DB", located on the Message Board at http://www.phpbuilder.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity