I cannot figure out the proper wording/syntax for the query statement. I want to check if there is a school already in our table (names schools) that matches the school name. If so, the state it already exists. Any input would be great!
//create a connection (the connection is made in another php file)
$obj = new MyConnection();
$obj->setConn();
$obj->displayValues();
$qObj = new MyCode();
$qObj->setConn( $obj->getConn());
//Query to put all the school data into db
$q1 = "INSERT INTO schools(
SchoolName,
SchoolWebsite,
City,
State,
Locale,
Sector,
Tuition,
GradRate,
FacToStudRatio,
StudentPop,
FreshmenPop,
PercentWomen,
PercentMen,
PercentAdmitted,
AverageGpa,
AverageScore)
VALUES ('$SchoolName',
'$SchoolWebsite',
'$City',
'$State',
'$Locale',
'$Sector',
'$Tuition',
'$GradRate',
'$FacToStudRatio',
'$StudentPop',
'$FreshmenPop',
'$PercentWomen',
'$PercentMen',
'$PercentAdmitted',
'$AverageGpa',
'$AverageScore')";
$findResult = pg_query( 'SELECT * FROM schools WHERE schoolname =.$SchoolName);
if ($findResult != 0)
{
echo "School Record Already Exists<br/>";
die;
}
$qObj->setQuery($q1);
$qObj->runQuery();