public static function getNews() {
$conn = new mysqli($servername, $username, $password, 'tubecareer');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = 'SELECT * FROM news ORDER BY time';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
foreach ($row['id'] as $news) {
echo '<div class="panel panel-info"><div class="panel-heading"><h4 class="panel-title">' . $news["topic"] . '</h3></div><div class="panel-body">' . $news["text"] . '</div></div>';
}
} else {
echo '<div class="panel panel-info">No Recent News!</div>';
}
}
if ($result->num_rows > 0) {
// output data of each row
foreach ($result as $news) {
print_r($news); // if this works then u will have all results from database then u use $news['name_of_field_what_u_need']
//echo '<div class="panel panel-info"><div class="panel-heading"><h4 class="panel-title">' . $news["topic"] . '</h3></div><div class="panel-body">' . $news["text"] . '</div></div>';
}
} else {
echo '<div class="panel panel-info">No Recent News!</div>';
}