Page 1 of 1

function call

Posted: Sat May 21, 2005 6:50 pm
by twb
Hi I am having a problem when calling a function. I have a function that populates numerous text boxes and echos the querry that was used displaying the employee_id...This all works. The problem is when I go to update it the same function is called and it cant find that employee_id... The function is still called..

Code: Select all

function Display_Employee_Details($employee_id){ 
$query = "Select * FROM employees WHERE employee_id = $employee_id"; 
$result = mysql_query($query); 
echo $query; 
if(!$result){ 
    echo 'Error in Search for Results:'.mysql_error(); 
    exit(); 
    } 
    else{ 
        //Get Results 
        global  $last_name,$first_name,$email,$city,$street,$unit_
no,$province,$country,$postal_code,$birth_date, $telephone,$oasis; 
        $row = mysql_fetch_array($result); 
        $last_name = $row['last_name']; 
        $first_name = $row['first_name']; 
        $email = $row['email']; 
        $city = $row['city']; 
        $street = $row['street']; 
        $unit_no = $row['unit_no']; 
        $province = $row['province']; 
        $country = $row['country']; 
        $postal_code = $row['postal_code']; 
        $birth_date = $row['birth_date']; 
        $telephone = $row['telephone']; 
        $oasis = $row['oasis']; 
    } 
}
Thanks
TWB

Posted: Sat May 21, 2005 7:33 pm
by Ambush Commander
Be a bit nicer about a failed query. If it can't find the employee, just return, say, a blank value or something.