php - random image not working correctly -
i have create array diusplay random file name mysql database. unfortunatly doesnt show correctly.
i need explode work based on file id show correct banner picturse tv series.
<?php include '../connect/dbseries.php' ?> <?php include 'sbarray.php' ?> <?php $names = explode ("|", $row['4']); ?> <center><?php while($row=mysql_fetch_array($result2)){ echo '<a href="episodemenu.php?id='.$row['id'].'"><img src="../images/series/'. $names[array_rand($names,1)].'" width="800" height="150" style="padding:2px;"></a>'; } ?> </center>
my array page
<?php $result2 = mysql_query("select id, pretty_name, sortname, genre, bannerfilenames, currentbannerfilename, posterfilenames, posterbannerfilename, summary, fanart, imdb_id online_series order sortname asc;"); if (!$result2) { echo 'could not run query: ' . mysql_error(); exit; } ?> <?php $row = mysql_fetch_row($result2); //setup array $banner = $row['4']; ?>
that code have on page. appreciated shows images row 1 instead of each row/ tv series
i asume has explode command cant figure out how correct it.
thanks in advance
you can check print_r($names)
whether works. if understand problem correctly, want random pic of each row. variable names before iterating through results - uses first:
<?php $result2 = mysql_query("select id, pretty_name, sortname, genre, bannerfilenames, currentbannerfilename, posterfilenames, posterbannerfilename, summary, fanart, imdb_id online_series order sortname asc;"); if (!$result2) { echo 'could not run query: ' . mysql_error(); exit; } ?> <center><?php while($row=mysql_fetch_assoc($result2)){ $names = explode ("|", $row['bannerfilenames']); //for check whether explode works print_r($names); echo '<a href="episodemenu.php?id='.$row['id'].'"><img src="../images/series/'. $names[array_rand($names,1)].'" width="800" height="150" style="padding:2px;"></a>'; } ?>
Comments
Post a Comment