Rifts Posted June 26, 2010 Share Posted June 26, 2010 Hey two things first how can I write if statements like this: if $total = 5 or 6 do this if $total = 10 or 11 or 12 do this if $total = 13 or 14 or 15 do this etc and secondly how do I display an image using php assuming its name is image.png and its in the same directory as my php file? thanks! Link to comment https://forums.phpfreaks.com/topic/205903-2-questions-in-1-math-and-images/ Share on other sites More sharing options...
murdocsvan Posted June 26, 2010 Share Posted June 26, 2010 Hey two things first how can I write if statements like this: if $total = 5 or 6 do this if $total = 10 or 11 or 12 do this if $total = 13 or 14 or 15 do this if($total => 5 && =<6) { do this } elseif($total => 10 && =<12) { do this } elseif($total => 13 && =<15 { do this } As for the second part? I'm not sure, where are you retrieving the file path for the image from? a database? or are you typing it yourself? usually you would do: <img href="<?php echo "/directory/image.png" ?>" /> Link to comment https://forums.phpfreaks.com/topic/205903-2-questions-in-1-math-and-images/#findComment-1077464 Share on other sites More sharing options...
Rifts Posted June 26, 2010 Author Share Posted June 26, 2010 thanks totally worked I actually ended up doing } elseif ($total == 13 || $total==14 || $total==15) { thanks for the image help too Link to comment https://forums.phpfreaks.com/topic/205903-2-questions-in-1-math-and-images/#findComment-1077466 Share on other sites More sharing options...
murdocsvan Posted June 26, 2010 Share Posted June 26, 2010 No problem, but you may want to use > and < symbols to determine a larger range of numbers. Link to comment https://forums.phpfreaks.com/topic/205903-2-questions-in-1-math-and-images/#findComment-1077584 Share on other sites More sharing options...
kenrbnsn Posted June 26, 2010 Share Posted June 26, 2010 BTW, this syntax <?php if($total => 5 && =<6) { do this } elseif($total => 10 && =<12) { do this } elseif($total => 13 && =<15 { do this } ?> is completely invalid. If I were doing this, I would use a switch statement: <?php switch ($total) { case 5: case 6: echo '$total is 5 or 6'; break; case 10: case 11: case 12: echo '$total is either 10, 11, or 12'; break; case 13: case 14: case 15: echo '$total is either 13, 14, or 15'; break; } ?> Ken Link to comment https://forums.phpfreaks.com/topic/205903-2-questions-in-1-math-and-images/#findComment-1077626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.