i am developing web application by using yii framework, i have a table called "studentinformation" and shown below
id name mothername phone classid parentname email
1. xxxxx asdf 9658741230 2 pqrs [email protected]
this is my another table
classid classname
1. class1
2. class2
3. class3
i am trying to import excel file data into database and In my excel file i gave classname instead of classid and convert from classname to classid and store into database everything working fine. this is my excel file columns with data
id name mothername phone classid parentname email
1. xxxxx asdf 9658741230 class10 pqrs [email protected]
My Requirement:- if i give wrong classname in my excel file which means that classname is not there in my database, at that time it should display one alert like "your class name is wrong" for example In above excel table i gave classid is "class10" but class10 is not there in my database table at that it should display some alert instead of this error "Trying to get property of non-object" here i am trying but i am not getting could you please help me..
$classdet = Classdetails::model()->findByAttributes(array('classname'=>'Class10','School_Id'=>1),'Status=1');
if($classdet->classname != 'Class10')
{
echo '<script language="javascript">';
echo 'alert("your classname is wrong")';
echo '</script>';
}
else{
print_r($classdet);
}