I have a class that i made, class art
in PHP. I want to copy data from a MySQL table to an array of class art
objects (array size varies depending on the tables number of rows).
The table containing the data has the same structure as my class art
.
SHORT VERSION: Is it possible to create an array of art
objects in PHP and how do I do that?
Here's the class that I have:
<?php
class art {
var $title='';
var $body='';
var $category='';
var $date='';
function does_whatever() { }
}
?>
Here's the mysql and code that should add each row of data as an 'art' object to an array:
$mysqli = new mysqli("localhost", "root", "", "blog");
$query = "select * from article";
if ($result = $mysqli->query($query))
{
while ($obj = $result->fetch_object())
{ //create the array of art type objects and add data to them
}
}
edit: i will eventually sort the array and echo the newest 5 articles
0 comments:
Post a Comment