Shoul this code work or is just sh%t?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

Shoul this code work or is just sh%t?

Post by Perfidus »

I want PHP to write a radio button only if condition is ok, but I do not what I'm doing wrong because I´m getting an error:

Code: Select all

<? 
if ($row['ene1d']!=0)
{
echo"<input type='radio' name='ene1t' value='"
.$valor1=$row["ene1"]; $ene1t=$valor1+(($valor1*10)/100)+((($valor1*10)/100)*16/100); echo round($ene1t);.
"'>";
}
?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

what error you getting?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i can see that your code is wrong - quite wrong actually - what you trying to do?

Mark
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I really don't see the benefit of trying to cram so many lines of code (as deliminated by the ;'s) onto one. When you start separating them out your code becomes easier to debug, and you may find the problem more apparent:

Code: Select all

if ($row['ene1d']!=0)
{
	echo '<input type="radio" name="ene1t" value="'.$valor1=$row['ene1']; 
	$ene1t = $valor1 + (($valor1*10)/100) + ((($valor1*10) / 100) * 16 / 100);
	echo round($ene1t);
	."'>";
}
That's the code broken up - can you see the problems now?

Note to others - give the guy a chance to figure it out himself pretty please.

Mac
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

twigletmac wrote:Note to others - give the guy a chance to figure it out himself pretty please.

Mac
The Mac has spoken, resistance is futile! 8)

-Nay
Post Reply