Jump to content

Help with if/else in DELETE


christalix

Recommended Posts

Hello,

Sorry to bother you guys.

 

If l have a variable called $value and this value fetches array from my database.

 

ex.

 

 

$xyz=mysql_query("SELECT contentext FROM blablabla WHERE parent is NUTLL);

 

foreach($xyz as $value =>$key){

echo $value[1][0]['contenttext'];

//where 0 is my error messages and 1 is my reuslt

}

 

then, l have

 

$xyz2=mysql_query("SELECT contentext FROM blablabla WHERE is_campaign is NOT NULL AND parent IS NOT NULL);

 

foreach($xyz2 as $value2 =>$key2){

echo $value2[1][0]['contenttext'];

}

 

 

 

So now if l am working on two different delete buttoms. I will like the delete.gif to be red if nothing is in the $value.

 

l went this way:

 

if(is_num($value > 0){

 

echo " you can not delete since the $value has a $value2 contents in it";

 

}else{

echo " You can delete this $value 2 since it contains no $value content";

 

}

 

 

 

This is not working mich for me.

 

Any tip on doing this ?

 

 

Thanks

Edited by christalix
Link to comment
Share on other sites

Well, l will try that at the job place tomorrow. it is like the $value is the parent and under the $value are the children $value2.

 

 

So if there are no $value2 in $value, then deleting should be able with else not able to be deleted.

 

It is mostly on this parent and children databse.

 

The $value and $value2 calues are in the databse which ar ebeing called out with the foreach loop............>

 

I will try !!

Link to comment
Share on other sites

are you selecting form the same table or from two different tables? You can build your select query better with sub-query. and make your code more simple and easy to handle.

 

I think you are selecting from 1 table (or even 2 tables), the thing is you want to delete the records where the conditions are true, you can also use:

 

if(condition1 && condition2){

 

}

else{

 

}

 

Quyen,

Edited by quyen
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...