i had a problem with looping data from mysql using OOP style.
so, here is my code:
class mysql {
private $host;
private $username;
private $password;
private $database;
public $con;
public function connect($setHost, $setUsername, $setPassword, $setDatabase) {
$this->host = $setHost;
$this->username = $setUsername;
$this->password = $setPassword;
$this->database = $setDatabase;
$this->con = mysqli_connect($setHost, $setUsername, $setPassword, $setDatabase);
}
public function query($setQuery) {
$query = mysqli_query($this->con, $setQuery);
return $query;
}
public function fetch($setFetch) {
$fetch = mysqli_fetch_assoc($this->query($setFetch));
return $fetch;
}
}
$objMysql = new mysql();
$con = $objMysql->connect("localhost" , "root" , "root" , "test");
while ($dataSlideshow = $objMysql->fetch("SELECT * FROM slideshow)) {
<h1><?php echo $dataSlideshow['images']; ?></h1>
}
the problem was, when i refreshing the page, it excutes without limited in the page, i dont know why, but, in mysql table, it contains only three slideshow? so, my computer got hang, and force to close the browsers. what's wrong with my code here?