HI, please help me get the right code for my logic below in php. I am a beginner in PHP and I can’t get the right code to make it work. I did some coding but not sure if I am in the right way. Please help me. I am about to pull my hair. I am really desperate to make this work. I hope you can help me please.
Basically, the logic are:
I have 18 textbox a-r. I want to check if those textbox are not empty using for (i=3; i< 18; i++) if not empty, I want to get the label of the textbox and check in the database if exist (comparing label = desnum) if it exist in the database (database include 3 column: desnum, agencyname, Impact_ID) I want to get the Impact_ID and write it to the 5 hidden textbox if exist with unique Impact_ID only and cannot be duplicated In the database, my unique is desnum, agencyname that is associated to one of the Impact_ID such as (Homeless, Childhood, ER, Finance, Crime) If one of the Impact_ID exist in the hidden textbox, move to the other textbox until it has one that doesn't exist in the hidden textbox.Here is my php code I created:
PHP Code:
[php]$j = 0;
$homeless = 0;
$childhood = 0;
$emergency = 0;
$crime = 0;
$financial = 0;
for ($i=3; $i<18; $i++)
{
if ($donation[$i] != “”)
{
for ($k=0; $k<sizeof($designation); $k++)
{
foreach ($desnum as $impact => $issue)
{
if ($issue == “Homelessness”)
{
if (empty($clean[‘impact1’]))
{
if ($homeless != 1)
echo $_POST[‘impact1’] = “Homelessness”;
$homeless = 1;
}
}
else if ($desnum == "Early Childhood Development")
{
if (empty($clean['impact2']))
{
if ($childhood != 1)
{
echo $_POST['impact2'] = "Early Childhood Development";
$childhood = 1;
}
}
}
else if ($impact == "Financial Stability and Independence")
{
if (empty($clean['impact3']))
{
if ($financial != 1)
{
echo $_POST['impact3'] = "Financial Stability and Independence";
$financial = 1;
}
}
}
else if ($impact = "Emergency Crisis and Services")
{
if (empty($clean['impact4']))
{
if ($emergency != 1)
{
echo $_POST['impact4'] = "Emergency Crisis and Services";
$emergency = 1;
}
}
}
else if ($impact == "Crime and Drug")
{
if (empty($clean['impact5']))
{
if ($crime != 1)
{
echo $_POST['impact5'] = "Crime and Drug";
$crime = 1;
}
}
}
}
}
} [/php]
and this is my html table:
PHP Code:
[code]
Crime what is this? |
Childhood what is this? |