Sunday 15 February 2015

trouble while checking if a number is a multiple of an other in php -



trouble while checking if a number is a multiple of an other in php -

i have problem while checking if number multiple of other. website, have queries in functions.

to simple,

i have query looks informations in database. , display informations in divs. if number of results multiple of 3, display not want :

what want do, if, number of result multiple of 3, add together other div in style visibility hidden, visual

for doing i've tried homecoming in function mysql_num_rows result , work number in loop.

my function that

function fetchlistehome($id_cat) { $query = "select `spb_maison_kit_detail_reference`, `spb_maison_kit_detail_superficie`, `spb_maison_kit_detail_prix`, `spb_maison_kit_detail_url_img`, `spb_maison_kit_detail_id` `spb_maison_kit_detail` `spb_maison_kit_detail_id_categorie` = '{$id_cat}'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); $result['num_rows'] = $num_rows; homecoming $result; }

if can have number of results, can check in loop, lastly iteration, , check if multiple of 3, if case, can display hidden div.

actualy homecoming me error, can not work number of rows

below error displayed

warning: cannot utilize scalar value array

anykind of help much appreciated.

you need fetch results of query before have access $result array this:

$result = mysql_query($query); $num_rows = mysql_num_rows($result); $row = mysql_fetch_array($result); // add together line $row['num_rows'] = $num_rows; homecoming $row;

php while-loop modulo

No comments:

Post a Comment