Jump to content

[SOLVED] quick question


serverman

Recommended Posts

would it have been better to use case over if in this snippet of my script.

<?php// Below checks to see if anything was forgotten!!!!  //
if ($q1 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q2 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q3 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q4 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q5 == "") {
  die ("You forgot something, go back and check over your quiz.");
}if ($q6 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q7 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q8 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q9 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q10 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
// Below is where the answers are checked actually displayed //?>

Link to comment
https://forums.phpfreaks.com/topic/106987-solved-quick-question/
Share on other sites

If it's the same die statement, just use 1 if:

<?php// Below checks to see if anything was forgotten!!!!  //
if (empty($q1) || empty($q2) || empty($q3) || empty($q4) || empty($q5) || empty($q6) || empty($q7) || empty($q8) || empty($q9) || empty($q10)) {
  die ("You forgot something, go back and check over your quiz.");
}
// Below is where the answers are checked actually displayed //?>

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.