Jump to content

If Work In Database


Cooper94

Recommended Posts

<?php
<?php 
foreach($clientlist as $client)
    { 

if((!strstr($client['29'] , "Naples Flying Club"))){
echo 'online';
}else{}
}
?>

 

I am trying to have it as if client['29'] has the words naples flying club in his comments it will show online! I thought the code strstr search's if the word is in that area.

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/
Share on other sites

if it's a multi-dimensional array, use the 2nd one, otherwise, use the first:

<?php
foreach ($clientlist as $client){
if (stristr($client, "naples flying club")){
	echo "online";
}
else{
	echo "offline";
}
}
/* or this will do it....hopefully */
foreach ($clientlist as $client){
if (stristr($client[29], "naples flying club")){
	echo "online";
}
else{
	echo "offline";
}
}

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818528
Share on other sites

<?php
<?php 
foreach($clientlist as $client)
    { 

if((!strstr($client['29'] , "Naples Flying Club"))){
echo 'online';
}else{}
}
?>

 

I am trying to have it as if client['29'] has the words naples flying club in his comments it will show online! I thought the code strstr search's if the word is in that area.

 

unless your clientlist array is multidimensional, the client variable wont be an array, (when you loop through an array with foreach, the variable after the "as" is a a variable equal to the current entry of the array you are accessing)

 

 

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818533
Share on other sites

Thank you guys so much and one more thing. On the code strstr function is there a way to make it delete content from up to down? So say I have hello world I want it to go down and just result hello. I know that it only goes up so all I know it would do is say world.

 

Thank You

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818689
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.