Jump to content

need help in if statement


shreef_1990

Recommended Posts

need help in if statement i will use it wordpress

 

i am semi brand new in php and html i forged it with the help of c and c ++ visual basic  LOL

and some tutorial but did not work if any one can help making it work

 

<?php

$Shreef = <?php echo "get_post_meta($post->ID, 'sub', true);" ?>

if ($Shreef=="Subbed"){

<font color="green">

<?php echo "get_post_meta($post->ID, 'sub', true);" ?>

</font>

                      }

else   {

if ($Shreef=="Raw")

<font color="red">

<?php echo "get_post_meta($post->ID, 'sub', true);" ?>

</font>

else { <?php echo "get_post_meta($post->ID, 'sub', true);" ?>}

 

  }

?>

Link to comment
Share on other sites

need help in if statement i will use it wordpress

 

i am semi brand new in php and html i forged it with the help of c and c ++ visual basic  LOL

and some tutorial but did not work if any one can help making it work

 

<?php
if(isset($_POST['sub'])){


$Shreef = $post->ID, 'sub', true);" ?>
if ($Shreef=="Subbed"){
					<font color="green">
					<?php echo "get_post_meta($post->ID, 'sub', true);" ?> 
					</font>
                      }
else				  {
					if ($Shreef=="Raw")
					<font color="red">
					<?php echo "get_post_meta($post->ID, 'sub', true);" ?> 
					</font>
					else { <?php echo "get_post_meta($post->ID, 'sub', true);" ?>}

				  }
?>

 

<?php marks the start of the php code.

?> marks the end of the php code.

 

Don't start it again before you have ended it. :P

 

Turn on error reporting, so you get some idea about what is wrong and what it expects.

 

$_POST[] is the variable/array for post data, but I'm not sure if that's what you are trying to do, neither have I worked with wordpress.

 

EDIT:

You never ended the CODE tag, so the code tag was added on the end of my post...

Link to comment
Share on other sites

it did not work

look forget it was wordpress

<?php echo "get_post_meta($post->ID, 'sub', true);" ?> == return string value i stored in shreef

i want to color this string value

so i used if

if string value was subbed print green "subbed "  from the answer of if

and have two other answer so i used two other else

 

but it did not complete first start <?php

did not read  final

?>

 

and so i needed to know if there are some special character i had to escape and how

 

 

<?php
$Shreef = <?php echo "get_post_meta($post->ID, 'sub', true);" ?>
if ($Shreef=="Subbed"){
					<font color="green">
					<?php echo "get_post_meta($post->ID, 'sub', true);" ?> 
					</font>
                      }
else				  {
					if ($Shreef=="Raw")
					<font color="red">
					<?php echo "get_post_meta($post->ID, 'sub', true);" ?> 
					</font>
					else { <?php echo "get_post_meta($post->ID, 'sub', true);" ?>}

				  }
?>

 

Link to comment
Share on other sites

it did not work

look forget it was wordpress

<?php echo "get_post_meta($post->ID, 'sub', true);" ?> == return string value i stored in shreef

i want to color this string value

so i used if

if string value was subbed print green "subbed "  from the answer of if

and have two other answer so i used two other else

 

but it did not complete first start <?php

did not read  final

?>

 

and so i needed to know if there are some special character i had to escape and how

 

 

<?php
$Shreef = <?php echo "get_post_meta($post->ID, 'sub', true);" ?>
if ($Shreef=="Subbed"){
					<font color="green">
					<?php echo "get_post_meta($post->ID, 'sub', true);" ?> 
					</font>
                      }
else				  {
					if ($Shreef=="Raw")
					<font color="red">
					<?php echo "get_post_meta($post->ID, 'sub', true);" ?> 
					</font>
					else { <?php echo "get_post_meta($post->ID, 'sub', true);" ?>}

				  }
?>

You still seem to start PHP again after having started it without ending it first.....

Just in the two first lines of the code you start PHP twice and not before the end of the line you end it.

This as far as I know is wrong.

 

<?php
$Shreef = get_post_meta($post->ID, 'sub', true);
if($Shreef=='Subbed'){
echo '<font color="green">'.$Shreef.'</font>';
}elseif($Shreef=='Raw'){
echo '<font color="red">'.$Shreef.'</font>';
}else{
echo $Shreef;
}
?>

^ Proper code.

Link to comment
Share on other sites

as i do not know i did not know about

 

You still seem to start PHP again after having started it without ending it first.....
Just in the two first lines of the code you start PHP twice and not before the end of the line you end it.
This as far as I know is wrong.

 

as for what i know

 

Your editing is working really good Working

 

Thanks my friend

Link to comment
Share on other sites

as i do not know i did not know about

 

You still seem to start PHP again after having started it without ending it first.....
Just in the two first lines of the code you start PHP twice and not before the end of the line you end it.
This as far as I know is wrong.

 

as for what i know

 

Your editing is working really good Working

 

Thanks my friend

 

I can't edit the post that long after I posted it. I edited the post mainly because it first wasn't possible to see due to an code tag at the end of my post. It somehow got connected with your post. That I had to edit, and I think I fixed a typo or two.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

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