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!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm new to php and I need to wrap an if statement around a group of php/html and don't know how to go about it...if anyone could help, that would be great...
I need to make the following chunk of code display based on the if statement below:
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Cool...thanks for switching code to php...didn't see that...
So, I tried this and it worked, but I need to make the display of the second input type (Add to Cart) conditional as well and I'm not sure where to put the if statement. I imagine I'll have to switch some of the parameters to a php call??
Hmm...I'm afraid I'm not following you. I tried to wrap a php tag around the entire second input name line, but setting the entire line in an echo came back with an error...
are there certain things you can't include in an echo statement?
<?php
$show_chunk = false;
$upper = 10;
$lower = 5;
// Get ready to bop out of PHP
if ($show_chunk):
?>
<p>This means that Show Chunk was set to true because you see this.</p>
<?php
// Okay, bop back in
endif;
// Now lets try it again
if ($lower < $upper):
?>
<p>This means that the variable lower is less than the variable upper.</p>
<?php endif; ?>
There are a few ways to do what you want. What I posted here is an alternative syntax. You would also do something like this:
<?php
$show_chunk = false;
$upper = 10;
$lower = 5;
// Get ready to bop out of PHP
if ($show_chunk) {
?>
<p>This means that Show Chunk was set to true because you see this.</p>
<?php
// Okay, bop back in
}
// Now lets try it again
if ($lower < $upper) {
?>
<p>This means that the variable lower is less than the variable upper.</p>
<?php } ?>
<?php
$show_chunk = false;
$upper = 10;
$lower = 5;
// Show stuff without leaving PHP
if ($show_chunk) {
echo '<p>This means that Show Chunk was set to true because you see this.</p>';
}
// Now lets try it again
if ($lower < $upper) {
echo '<p>This means that the variable lower is less than the variable upper.</p>';
}
?>