Loop does thing once only

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
malikov
Forum Newbie
Posts: 2
Joined: Mon Mar 02, 2009 1:42 pm

Loop does thing once only

Post by malikov »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Hi,

I've been banging my head all day and I can't figure it out.

Code: Select all

$find = strip_tags($find); 
$find = trim($find); 
$find = strtoupper($find); 
 
    $data = mysql_query("SELECT * FROM profiles"); 
    while ($ss1 = mysql_fetch_array( $data ))
    {$ss3=$ss1['keywords']; $ss4=(explode(",",$ss3));
 
for ($x=0; $x<count($ss4); $x++){
             
$ss5=strip_tags($ss4[$x]);
$ss5=trim($ss4[$x]);
$ss5=strtoupper($ss4[$x]);
 
 if ($find==$ss5){ $profile=$ss1['name']; $pro_lvl=$ss1['prolvl'];
    $query=("insert into search(profile,pro_lvl,id) values ('$profile','$pro_lvl','$id')");
    $result = mysql_query($query);
}}}

It's supposed to insert all matches into table, but it only does if the first object ([0]) matches.
If it's [3] loop doesn't see it.


Please help ASAP.


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Loop does thing once only

Post by php_east »

i think you want

$ss5=strip_tags($ss4[$x]);
$ss5=trim($ss5);
$ss5=strtoupper($ss5);
malikov
Forum Newbie
Posts: 2
Joined: Mon Mar 02, 2009 1:42 pm

Re: Loop does thing once only

Post by malikov »

php_east, you are a mind savior. I've been looking at this for hours, going mad. Thank you very much.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Loop does thing once only

Post by php_east »

send me a beer, send me a beer, quick ! ... :drunk:
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Loop does thing once only

Post by josh »

I guess we're starting to learn the difference between syntax & semantics ;-) Always use names that are obvious.
Post Reply