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
https://forums.phpfreaks.com/topic/260812-need-help-in-if-statement/
Share on other sites

  Quote

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

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);" ?>}

				  }
?>

 

  Quote

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.

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

  Quote

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.

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.