Need help on if..else statement

Hi

I am using the if…else statement to help me to solve some queries.
Here’s the code:

 		/////////////////////
		///
		///	LATEST DATA
		///
		/////////////////////

 while ($row_export = mysql_fetch_array($result_export, MYSQL_ASSOC))
{	
	
		/////////////////////////////////
		///              OPTION 1
		///	DATABASE ON EXISTING TABLE
		///
		/////////////////////////////////

                   $sql_test = "SELECT *
				FROM wsdevice ";

	if (trim($pib_bracket_num) !='' and trim($HW_design) !='' )
	{				
	$sql_test .=" WHERE ((wsdevice_pibid like '%$pib_bracket_num%') and  
                      (device_designid = '$HW_design')) ";
		
	$results = mysql_query($sql_test) 
		or die ("NO SEARCH TERMS"); 
				
		//echo $results ;	
		
       while ($row = mysql_fetch_array($results, MYSQL_ASSOC))
             {

		/////////////////////////////////
		///          OPTION 2
		///	DISPLAY EXISTING DATA IN 
		///          TABLE FORM
		/////////////////////////////////

		/////////////////////////////////
		///
		///	DISPLAY UPDATE ON LATEST DATA
		///              IN TABLE FORM
		/////////////////////////////////

             } 
       } else 
          {

           echo $HW_dev_num;

		/////////////////////////////////
		///           OPTION 3
		/// DISPLAY LATEST DATA NOT UPDATED
		///         
		/////////////////////////////////

           }
        
}

Just wondering if there’s any code i can use in order to satisfy the query statement whereby if $sql_test .=" WHERE ((wsdevice_pibid like ‘%$pib_bracket_num%’) and (device_designid = ‘$HW_design’)) "; is true, it will proceed to option 2 and if it doesn’t satisfy the query, it will move to option 3 ?

Basically,this is what i did.



$op2shown = false;
 while ($row = mysql_fetch_array($results, MYSQL_ASSOC))
  {
           
$op2shown = true;
.
.
.
}

if (!$op2shown)
{
.
.
.
}




Great!
Why don’t you post the solution, to the benefit of others? :slight_smile:

That’s some bad looking code…
There’s no flow, no nice tabbing/spacing etc…

problem solved!!