Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
krmaet
/
Lennubroneerimis_tarkvara
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
76a35155
authored
Mar 29, 2023
by
karade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
19215a6d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
addflights.c
addflights.c
0 → 100644
View file @
76a35155
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'
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment