Im creating a basic website that will show 10 different tv programmes.
I have the 10 different programmes stored in the database. Im able to retriev the 10 programmes but they all appear in a column.
I was wondering if theres a way to have then appear 5 in a row?
I have tried basic CSS but i cant seem to get it working
Here is the code i have so far:
$results = $mysqli->query("SELECT * FROM programmes ORDER BY ProgrammeName ASC");
if ($results) {
while($obj = $results->fetch_object())
{
echo '
';
echo '
echo '
';echo '
echo '
'.$obj->ProgrammeName.'
';echo '';
echo '
}
}
?>
I was wondering if theres a way to achive that i want or will i have to try something else?
anything will help.
Thanks!
解决方案
Try to put them in a table:
$results = $mysqli->query("SELECT * FROM programmes ORDER BY ProgrammeName ASC");
if ($results) {
$i=0;
echo '
while($obj = $results->fetch_object())
{
echo '
';echo '
echo '
';echo '
echo '
'.$obj->ProgrammeName.'
';echo '';
echo '
echo '
$i++;
if ($i == 5) {
echo '
';}
}
echo '
';}
?>