Комментарии:
Great tutorial. Simple and ez to understand. Many tutorial out there are using classes. It make me confused 😵
ОтветитьThis code gives me an Internal Server 500 Error so I updated the code if anyone getting same error use my code - <?php
$con = mysqli_connect("localhost", "root", "", "{database_name_isert_here}");
$response = array();
if ($con) {
$sql = "SELECT * FROM {table_name_insert_here}";
$result = mysqli_query($con, $sql);
if ($result) {
// Set the correct Content-Type header
header("Content-Type: application/json");
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
$response['data'] = $rows; // Store the data in an associative array
echo json_encode($response, JSON_PRETTY_PRINT);
} else {
// Handle query execution error
$errorResponse = array('error' => 'Query execution failed');
echo json_encode($errorResponse);
}
// Close the database connection
mysqli_close($con);
} else {
// Handle database connection error
$errorResponse = array('error' => 'Database connection failed');
echo json_encode($errorResponse);
}
?>
please make a video on information about MySql, Sqlite what is the need and difference between
and what is php plugins?
where is the code
Ответитьhow to do a post rquest?
Ответитьdo you have an actual tutorial that connects to a thrid party api
Ответитьaahhh thanks you guyz completely wrecked my 2 hour , in the line no 5 there `data` should bein back thick 😤😤😤😤
Ответитьthank you bro
ОтветитьBro this is not a API its just a Database query
ОтветитьThis is good but how to protect of other people, every guy who know how to use fetch in javascript can get data from db using this method. This isnt secured bro.
ОтветитьGood Tutorial Bro.
Is there a way that instead of calling all the data. We can only get one we required. Creating an API that somehow asks to enter the name and will only return data containing that name
Thanks
This is not an api... lots of paid commenters.
ОтветитьVery informative & to the point
Helped me a lot in making an API that I want to use with ReactJS
Is this API???? you've just connected mySql. Api is different :)
Ответитьmslqi code
<?php
$mysqli = new mysqli("localhost","root","","API_DATA");
$response = array();
if ($mysqli->ping())
{
$db = "select * from data";
$result = mysqli_query($mysqli,$db);
if($result){
header("Content-Type: JSON");
$i=0;
while($row = mysqli_fetch_assoc($result)){
$response[$i]['id'] = $row['id'];
$response[$i]['name'] = $row['name'];
$response[$i]['age'] = $row['age'];
$response[$i]['email'] = $row['email'];
$i++;
}
echo json_encode($response,JSON_PRETTY_PRINT);
}
}
?>
I love you
ОтветитьReally Easy to understand, good work
Ответитьwhen I run the file, it says "Not found". why?
ОтветитьThanks dear sir
ОтветитьThanks for your tutorial very easy to understand.
Ответить