-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-bet3.php
31 lines (31 loc) · 1.38 KB
/
add-bet3.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
include("db-connection.php");
$sql_category = "SELECT id_category FROM category WHERE category.name = '" . $category_name . "'";
$result_category = mysqli_query($db, $sql_category);
$id_categories = [];
while ($row = mysqli_fetch_row($result_category)) {
$id_categories[] = $row;
}
$sql_region = "SELECT id_sub_category FROM sub_category WHERE sub_category.name = '" . $region_name . "'";
$result_region = mysqli_query($db, $sql_region);
$id_regions = [];
while ($row = mysqli_fetch_row($result_region)) {
$id_regions[] = $row;
}
$sql_event = "SELECT id_sub_sub_category FROM sub_sub_category WHERE sub_sub_category.name = '" . $event_name . "'";
$result_event = mysqli_query($db, $sql_event);
$id_events = [];
while ($row = mysqli_fetch_row($result_event)) {
$id_events[] = $row;
}
$sql_bet = "INSERT INTO bet_entity(name, category, sub_category, sub_sub_category, data) VALUES('"
. $bet_name ."', '". $id_categories[0][0] ."', '". $id_regions[0][0] ."', '". $id_events[0][0] ."', '".
$event_date ."')";
if ($db->query($sql_bet) === TRUE) {
$id_bet_entity = mysqli_insert_id($db);
echo "<div class='alert alert-success' role='alert'><h3 class='h4 mb-3'>🎈 Pomyślnie dodano zakład!</h3></div>";
include("add-bet4.php");
} else {
echo "<div class='alert alert-danger' role='alert'><h3 class='h4 mb-3'>❌ Nie udało się dodać zakładu</h3></div>";
}
mysqli_close($db);