2uzhan.com
Advertisement
Now Place:2uzhan.com » Error display not working

Error display not working

PHP @ October 1, 2005   Views:0

Hi I'm wondering how i would display the error message I have in here properly... its supposed to only display when I don't have data. But even when I do have data, it still displays:

The error has something to do with $title_display not working properly.

PHP Code:

if (isset($BASIC)){

$sql = "select * from areas ORDER BY sortingorder ASC";

$result = mysql_query($sql);

while ($owners = mysql_fetch_array($result)) 
        {

$id=$owners['id'];
            $area2=$owners['name'];
            $shows=$owners['shows'];
    
    
    
            $sql2 = "select * from project_master, newproject_data WHERE newproject_data.nprojectID = project_master.nprojectID AND project_master.area1 = '$area2' AND newproject_data.published = 'YES' AND newproject_data.date = '$issue_select' ORDER BY project_master.project_address ASC";
    
            $result2 = mysql_query($sql2);
            $num_rows = mysql_num_rows($result2);
        
        $title_display == 1;
        if ($num_rows == 0){
        
        /* CODE TO GENERATE ERROR MESSAGE IF THERE ARE NO RESULTS FOR THAT ISSUE */
        
        if ($title_display == 1) {
        echo "<br><br><span class=alerts2><font color=#000000>Please return to the last issue for information under this heading, or select another component.<br>If you believe this message is in error, please contact our office.</font></span>";
        }
        $title_display == $title_display ++;
        
        }else{
        
        
        
                while ($south = mysql_fetch_array($result2)) 
                {
        
        
                    $nprojectID=$south['nprojectID'];
                    $area1=$south['area1'];
                    $issue_date=$south['issue_date'];
                    $updissue_date=$south['updissue_date'];
                    $last_issue=$south['last_issue'];
                    $project_address=$south['project_address'];
                    $project_type=$south['project_type'];
                    $comments=$south['comments'];
                    $project_description=$south['project_description'];
                    $newproject=$south['newproject'];
                    $updatedproject=$south['updatedproject'];
                    $prebid=$south['prebid'];
                    $newtender=$south['newtender'];
                    $updatedtender=$south['updatedtender'];
                    $bidresults=$south['bidresults'];
                    
                    
            /************************************* BEGIN PROJECT DISPLAY **************************************/
                    
                    echo "<tr><td colspan=3><br><br><span class='area-title'><strong>$area1</strong></span><span class=bodytext> - $project_address (<span class=published-text2>$project_type</span>) - $project_description</span></td></tr>";
                            
            /************************************* END PROJECT DISPLAY **************************************/
                              
                              
            /************************************* BEGIN PROJECT DETAIL DISPLAY **************************************/                        
            
                /* This is the category name */
                
                $sql = "SELECT * FROM project_crosslink WHERE projectID = $nprojectID ORDER BY orderID,category";
                
                $results = mysql_query($sql);
                
                while ($crosslink = mysql_fetch_array($results)) 
                {    
                    $catID = $crosslink['catID'];
                    $detailID = $crosslink['detailID'];
                    
                    $sql2 = "SELECT * FROM category WHERE catID = $catID";
                    
                    $results2 = mysql_query($sql2);
                    
                    $category_results = mysql_fetch_array($results2);
                    
                    $name = $category_results['catSelect'];
                    $catID_match = $category_results['catID'];    
                    
                    $sql3 = "SELECT description FROM projectdata_details WHERE projID = $detailID";
                    
                    $results3 = mysql_query($sql3);
                    
                    $details_results = mysql_fetch_array($results3);
                    
                    $detail = $details_results['description'];
                    
                    
                    //// RESTRICT CATEGORIES TO THE FOLLOWING ////
                    $restrict = array(123, 124, 125, 126, 127, 128, 129, 130, 131); 
            
                    if(!in_array($catID_match, $restrict)) 
                    {
                    
                        echo"<tr>";
                        echo"<td width='150' valign=top>";
                            echo "<span class='headers3'>$name</span>";
                        echo"</td>";
                        echo"<td width='8' valign=top>";            
                            echo"<span class='bodytext'>:-</span><br>";
                        echo"</td>";
                        echo"<td valign=top>";            
                            echo"<span class='bodytext'>$detail</span><br>";
                        echo"</td>";
                        echo"</tr>";
                    
                    }
                    
                }
                            
            /************************************* END PROJECT DETAIL DISPLAY **************************************/    
            
            }
    
        }
        
    }

} ///END BASIC 

--------------Solutions-------------

Hi,

I'm still pretty new, but it looks like you might be using double equal signs in some spots where you only need single.

$this=$that will set the variable this to that.
$this==$that will check to see if both variables are the same.

HTH

Dolomite 50 is right, your syntax is all to pot. Single = assigns the value, double compares the 2 values.

PHP Code:


if (isset($BASIC)){

$sql = "select * from areas ORDER BY sortingorder ASC";

$result = mysql_query($sql);

while ($owners = mysql_fetch_array($result)) 
        {

$id=$owners['id'];
            $area2=$owners['name'];
            $shows=$owners['shows'];
    
    
    
            $sql2 = "select * from project_master, newproject_data WHERE newproject_data.nprojectID = project_master.nprojectID AND project_master.area1 = '$area2' AND newproject_data.published = 'YES' AND newproject_data.date = '$issue_select' ORDER BY project_master.project_address ASC";
    
            $result2 = mysql_query($sql2);
            $num_rows = mysql_num_rows($result2);
            
// set $title_dsiplay to 1  ***************        
        $title_display = 1;
        if ($num_rows == 0){
        
        /* CODE TO GENERATE ERROR MESSAGE IF THERE ARE NO RESULTS FOR THAT ISSUE */
        
// check if $title_display is still 1 ************       
        if ($title_display == 1) {
        echo "<br><br><span class=alerts2><font color=#000000>Please return to the last issue for information under this heading, or select another component.<br>If you believe this message is in error, please contact our office.</font></span>";
        }
        
// increment $title_display  ***********
        $title_display++;
        
        }else{
        
// etc. have not checked the rest of the code 

Tags:
© 2018 2uzhan.com Contact