Jump to content

[SOLVED] Group Error Checking


tobeyt23

Recommended Posts

Need to check a group of form inputs and want to run them in a group instead of separate statements. This is what i have so far and no luck any suggestions. I just put the form fields as variables in these to test and this is a far as I got before I realized this may not be the best way. Any suggestions?

 

Thanks

 

<?php

$exf1 = 1;
$exf2 = 0;
$exf3 = 1;
$exf4 = 0;
$exf5 = 0;
$exf6 = 1;

$ename1 = "Test";
$ename2 = "";
$ename3 = "";
$ename4 = "";
$ename5 = "";
$ename6 = "";

$etype1 = "";
$etype2 = "";
$etype3 = "";
$etype4 = "";
$etype5 = "";
$etype6 = "";

$edata1 = "";
$edata2 = "";
$edata3 = "";
$edata4 = "";
$edata5 = "";
$edata6 = "";


$extraFields = array($exf1, $exf2, $exf3, $exf4, $exf5, $exf6);

$t = 1;
foreach ($extraFields as $field) 
{
if ($field == 1)
{	
	echo $ename[$t];
}
$t++;
}

?>

Link to comment
Share on other sites

This seems to work:

 

<?php
$exf1 = 1;
$exf2 = 0;
$exf3 = 1;
$exf4 = 0;
$exf5 = 0;
$exf6 = 1;

$ename1 = "Test 1";
$ename2 = "Test 2";
$ename3 = "Test 3";
$ename4 = "Test 4";
$ename5 = "Test 5";
$ename6 = "Test 6";

$etype1 = "";
$etype2 = "";
$etype3 = "";
$etype4 = "";
$etype5 = "";
$etype6 = "";

$edata1 = "";
$edata2 = "";
$edata3 = "";
$edata4 = "";
$edata5 = "";
$edata6 = "";


$extras = array($exf1.":".$ename1.":".$etype1.":".$edata1, $exf2.":".$ename2.":".$etype2.":".$edata2, $exf3.":".$ename3.":".$etype3.":".$edata3, $exf4.":".$ename4.":".$etype4.":".$edata4, $exf5.":".$ename5.":".$etype5.":".$edata5, $exf6.":".$ename6.":".$etype6.":".$edata6);

$t = 1;
foreach ($extras as $extra) 
{
$setting = explode(':', $extra);
if ($setting[0] == 1)
{
	echo "Extra field ".$t." => ".$setting[1]."<br><br>\n";
}
$t++;
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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