using mobile orientation for display column in a div
Posted: Sun Jul 15, 2012 7:29 am
Hi
im having trouble in combining php with javascript ,
in short what i need to do if the mobile in 90 degrees(which is wider), so show div with 4 columns ,else(normal orientation) show 3 columns.
i dont know how to use both of javascript orientation detection and php which execute the columns.
im lost here dont know how to solve it . its not also to talk with the database with each detection , so i guess i need to use ajax save the data and than somehow play with javascript maybee with php.
thats the code which shows the columns :
<?php
$stmt = $db->query('SELECT * FROM rooms');
$count = $db->fetchOne( 'SELECT COUNT(name) AS count FROM rooms' );
for ( $ro = 0; $ro <$count/4; $ro++ )
{
echo '<div id="rom_wrap">';
for ( $column = 0; $column < 4; $column++ )
{
/*while ($row = $stmt->fetch()) {*/
$row = $stmt->fetch() ;
echo '<div class="naming" id="naming"><img src="'.$row['image'].'" id="imaging"></br>'.$row['name'].'</div>';
}
echo '</div>';
echo '<br />';
}
?>
im having trouble in combining php with javascript ,
in short what i need to do if the mobile in 90 degrees(which is wider), so show div with 4 columns ,else(normal orientation) show 3 columns.
i dont know how to use both of javascript orientation detection and php which execute the columns.
im lost here dont know how to solve it . its not also to talk with the database with each detection , so i guess i need to use ajax save the data and than somehow play with javascript maybee with php.
thats the code which shows the columns :
<?php
$stmt = $db->query('SELECT * FROM rooms');
$count = $db->fetchOne( 'SELECT COUNT(name) AS count FROM rooms' );
for ( $ro = 0; $ro <$count/4; $ro++ )
{
echo '<div id="rom_wrap">';
for ( $column = 0; $column < 4; $column++ )
{
/*while ($row = $stmt->fetch()) {*/
$row = $stmt->fetch() ;
echo '<div class="naming" id="naming"><img src="'.$row['image'].'" id="imaging"></br>'.$row['name'].'</div>';
}
echo '</div>';
echo '<br />';
}
?>