Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/plain');
- $servername = "mysql.cba.pl";
- $username = "1312Chef1312";
- $password = "chefff1312";
- $dbname = "chef_cba_pl";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $type = $_GET['type'];
- $receptureName = $_GET['receptureName'];
- $sql = "SELECT * FROM $type WHERE nazwaPotrawy = '$receptureName'";
- $result = $conn->query($sql);
- echo "{\n" . $type . ":[ \n";
- $i = 0;
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $i++;
- if($i < $result->num_rows) {
- echo "\t" . (json_encode($row) . ",\n");
- }
- else {
- echo "\t" . (json_encode($row) . "\n");
- }
- //$rows[] = $row;
- }
- }
- echo ']}';
- //echo json_encode($rows);
- $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement