Commit 76a35155 by karade

Add new file

parent 19215a6d
Showing with 59 additions and 0 deletions
void AddFlightDest(MYSQL* con)
{
char dest[STR_MAX];
char dot[STR_MAX];
int seats = 72;
char flightNum[STR_MAX];
char query[1024];
//kontroll kas sama lennunumbriga on juba moni lend
//muud asjad ei vaja kontrolli aga kuupäeva küsimises peaks formaadi
//näide olema
while(1)
{
puts("Enter flight number for new flight");
scanf("%s", flightNum);
sprintf(query, "SELECT flightNum FROM Flights WHERE flightNum = '%s'"
,flightNum);
if(mysql_query(con, query)){
printf("Error checking if flightNum exists %s\n", mysql_error(con));
exit(EXIT_FAILURE);
}
MYSQL_RES *result = mysql_store_result(con);
MYSQL_ROW row;
row = mysql_fetch_row(result);
if(strcmp(row[0],flightNum) == 0)
{
puts("Flight number already exists, choose another");
}
else
break;
}
sprintf(query, "INSERT INTO flights (destination, time"
"seats, flightNum) VALUES ('%s', '%s',%d '%s',);"
,dest, dot, seats, flightNum);
if (mysql_query(con, query)) { //päring serverile
printf("Error inserting user into database: %s\n", mysql_error(con));
exit(EXIT_FAILURE);
}
else
{
//Õnnestus teade'
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment