Hello,

I hope somone can help me.

I have a form that a user use to search for their pay, and it will dispay it for them as both with dependents and without.

Right now they can search and it will display their pay, but it displays it as two seperat rows. so it will display the pay in both the with and without section for the 'with' and then it does the same for the 'without'.

I have a database that has 2 tables sorted_zipmhaYY and bahwYY.

I would like to have it show 1 record that shows how much they will get with or without dependents. I have tried doing

if ($row['dependents']='with'){ ...}

if ($row['dependents']='without'){ ...}

But this just created a loop.

<div id="search_results">
        <?php


if(isset($_GET['zipcode'])){
    $zipcode =     trim($_POST['zipcode']) ;
$zipcode = mysql_real_escape_string($zipcode);
if(isset($_GET['field_rank'])){
    $rank =     trim($_POST['field_rank']) ;
$rank = mysql_real_escape_string($rank);
if(isset($_GET['YEAR'])){
    $year =     trim($_POST['YEAR']) ;
$year = mysql_real_escape_string($year);



$query = "SELECT $rank, ZIPCODE, Dependents, YEAR FROM sorted_zipmhaYY 
LEFT JOIN bahwYY ON sorted_zipmhaYY.MHA=bahwYY.MHA 
WHERE ZIPCODE='$zipcode' AND YEAR='$year' ORDER BY sorted_zipmhaYY.zipcode ASC";

echo $query;



//echo $query;

$result = mysql_query($query) or die(mysql_error());
if($result){
   /* if(mysql_affected_rows($link)!=0){*/
    
          while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
     echo '<div id="style"><p> <b> <small> Zipcode: </small>'.$zipcode.
     '</div></b></p><br />
<div id="style"><p> <b> <small> Year: </small>'.$row['YEAR'].
     '</div></b></p>
	 <div id="style"><p> <b> <small> Recomended BAH for a '.$rank.' with dependents: </small>$'.$row[$rank].
     '</div></b></p><br />
<div id="style"><p> <b> <small> Recomended BAH for a '.$rank.' without dependents Status: </small>'.$row[$rank].
     '</div></b></p> <hr>';
    }
    }else {
        echo 'No Results for Zipcode "'.$_POST['zipcode'].'"';
   /* }
 */
}
}else {
    echo 'Parameter Missing';
}
}
}
?></div>

Any help would be appreciated.

Thanks,

Aaron

for your first code use an elseif which will either display one or the other

if ($row[dependents]=='with'){
...
}elseif($row[dependents]=='without'){
...
}

Hello Public image, thank you, I'm not sure if an if elseif is what I need. Because what I am trying to do is display $row[$rank] for the values that have $row==with and $row==without.

Do you know how this can be done?

Thanks,

Aaron

for your first code use an elseif which will either display one or the other

if ($row[dependents]=='with'){
...
}elseif($row[dependents]=='without'){
...
}

Hi,

Nevermind, I got it working, sorry I made a newbie mistake.

thanks,

Aaron

Hello Public image, thank you, I'm not sure if an if elseif is what I need. Because what I am trying to do is display $row[$rank] for the values that have $row==with and $row==without.

Do you know how this can be done?

Thanks,

Aaron

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.