Help in checking if exist in database

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]



    <td style="float:right">  $<input id="d" name="d" class="text" type="text" value="<?php safeEcho($form['d'])?>" style="width:90px;" onChange="CalculateTotal();" /> 
 <?php helper_error('d');?> </td> <td> <input name="impact1" type="hidden"  />    
    <td style="float:right">  $<input id="e" name="e" class="text" type="text" value="<?php safeEcho($form['e'])?>" style="width:90px;" onChange="CalculateTotal()" /> 
 <?php helper_error('e');?> </td> <td> <input name="impact2" type="hidden" />    
            </tr> 
            <tr> 
                <td style="width:380px;text-align:left"><label for="f"  id="F" name="F">Emergency <a href="javascript:alert('Helping families ');">what is this?</a></label></td> 
     
    <td style="float:right">  $<input id="f" name="f" class="text" type="text" value="<?php safeEcho($form['f'])?>" style="width:90px;" onChange="CalculateTotal()" /> 
 <?php helper_error('f');?> </td><td> <input name="impact3" type="hidden" />    

            </tr> 
            <tr> 
                <td style="width:380px;text-align:left"><label for="g"  id="G" name="G">Financial<a href="javascript:alert('Providing programs');">what is this?</a></label></td> 
     
    <td style="float:right">  $<input id="g" name="g" class="text" type="text" value="<?php safeEcho($form['g'])?>" style="width:90px;" onChange="CalculateTotal()"/> 
 <?php helper_error('g');?> </td><td> <input name="impact4" type="hidden" />    

            </tr> 
            <tr> 
                <td style="width:380px;text-align:left"><label for="h"  id="H" name="H">Homelessness <a href="javascript:alert('Preventing families ');">what is this?</a></label></td> 
     
    <td style="float:right">  $<input id="h" name="h" class="text" type="text" value="<?php safeEcho($form['h'])?>" style="width:90px;" onChange="CalculateTotal()"/> 
 <?php helper_error('h');?> </td><td> <input name="impact5" type="hidden" />    

            </tr> 
Crime what is this?
Childhood what is this?
[/code]

Does anyone please help me with this logic? Sorry but I am not a php programmer and I am just trying to figure things up. Please help with the code. Thanks in advance.

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.
Sponsor our Newsletter | Privacy Policy | Terms of Service