Created
December 25, 2019 01:58
-
-
Save anta40/1db829be5bb299d8c1f745dcc5fc9c28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
$db = new mysqli("localhost","wpdev2019","test2019","wpblog1"); | |
if ($db->connect_errno) { | |
echo "Failed to connect to MySQL: " . $db-> connect_error; | |
exit(); | |
} | |
else { | |
$myArray = array(); | |
if ($result = $db->query("SELECT ID, post_title, post_name, guid, post_content, post_date from wpkk_posts")) { | |
$tempArray = array(); | |
while ($row = $result->fetch_object()) { | |
$tempArray = $row; | |
array_push($myArray, $tempArray); | |
} | |
echo json_encode($myArray); | |
} | |
$result->close(); | |
$mysqli->close(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment