Hi i am trying to display on the web browser to allow user to see information before the latest data is been updated. Hence, it will show:
(1)previous existing data,
(2)latest data and
(3)data which is not found on the latest data list
.

To make things clear to solve the problem, (1) is already stored in the database. (2) & (3) data is an extra information which will be use to update (1). Any up-to-date information will be overwrite (1) using PHP UPDATE feature.

I did manage to display all 3 information BUT for (3) i

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

 while ($row_export = mysql_fetch_array($result_export, MYSQL_ASSOC))
{	
	
		$HW_dev_num = $row_export['HW_dev_num'];	
		$platformexport	= $row_export['platform'];
		$HW_design	= $row_export['HW_design'];
		$rel_site	= $row_export['rel_site'];	


		/////////////////////////////////
		///
		///	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))
             {

		/////////////////////////////////
		///
		///	DISPLAY EXISTING DATA IN 
		///          TABLE FORM
		/////////////////////////////////

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

             } 
       } else 
          {

           echo $HW_dev_num;

		/////////////////////////////////
		///
		/// DISPLAY LATEST DATA NOT UPDATED
		///         
		/////////////////////////////////

           }
        
}

when i did "echo $HW_dev_num" after the else, i did not get any information which i tried to retrieve from the row at the very beginning for "$HW_dev_num = $row_export; "

should "$HW_dev_num" can pass down after the else statement??

Recommended Answers

All 6 Replies

I am wondering if i am to use a if statement after

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");  
                                 .
                                 .
                                 .

say if the queries is correct, it will pass down to the following while loop to process the update. But if the queries are not correct, it will skip and go straight down to the else statement to process the next queries.

Any idea what is the correct code to use to state the if..else statement for a query result????

Cheers

If you say that your result is not showing 3rd option, that is else part of your if condtion, then it means that your all rows in row_export is satisfying your following condition if (trim($pib_bracket_num) !='' and trim($HW_design) !='' ), so it is priting only option 1 and 2.

I think there is no php/mysql problem. YOu need to rework your code. if data for 3rd option exists.

yea i actually notice that too. So i was trying to rework my code to use the if..else statement after the queries as i posted here too.

Just wondering if there's any code i can use in order to satisfy my 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 1 and 2 and if it doesn't satisfy the query, it will move to option 3 ?

Hi

Are there anyway i can actually know if the true value is pass through after passing through the SELECT query?

I have set one flag before your while loop;
If while loop is executed then flag is true;
Now I have removed your else and written one if condition based on that flag, if option 1 and 2 is not shown then show option 3.

I hope this is what you are looking for.

$op1and2shown=false;
	while ($row = mysql_fetch_array($results, MYSQL_ASSOC))
             {
                 $op1and2shown=true;
		/////////////////////////////////
		///
		///	DISPLAY EXISTING DATA IN 
		///          TABLE FORM
		/////////////////////////////////
 
		/////////////////////////////////
		///
		///	DISPLAY UPDATE ON LATEST DATA
		///              IN TABLE FORM
		/////////////////////////////////
 
             } 
       } 

      If(!$op1and2shown)
          {
 
           echo $HW_dev_num;
 
		/////////////////////////////////
		///
		/// DISPLAY LATEST DATA NOT UPDATED
		///         
		/////////////////////////////////
 
           }

I have set one flag before your while loop;
If while loop is executed then flag is true;
Now I have removed your else and written one if condition based on that flag, if option 1 and 2 is not shown then show option 3.

I hope this is what you are looking for.

Thanks urtrivedi!!
That's what i m trying to look for.
Appreciate it so much.

Cheers :)

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.