Posted: Tue Jun 05, 2007 2:58 pm
Whats the simplest way to loop them using an if-else statement?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
foreach ($rlsdate, $avgrating, $genre)Code: Select all
foreach ($rlsdate, $avgrating, $genre as $arrayresults)Code: Select all
foreach($rlsdate as $dateItem) {
// do stuff with $dateItem here
}
foreach($avgrating as $ratingItem) {
// do stuff with $ratingItem here
}
foreach($genre as $genreItem) {
// do stuff with $genreItem here
}Code: Select all
<?php
$rlsdate = array('last30', 'last60', 'last90', 'last6mth', 'lastyr', 'overayr');
$avgrating = array('4ormore', '3ormore', '2ormore', '1ormore');
$genre = array('action', 'animation', 'kids', 'comedy', 'docu', 'drama', 'horror', 'musical', 'scifi', 'thriller');
foreach($rlsdate as $date) {
}
foreach($avgrating as $arating) {
}
foreach($genre as $genreItem) {
}
?>Code: Select all
<?php
foreach ($array as $value) {
echo '<p>' . $value . '</p>';
}
?>Code: Select all
<?php
$rlsdate = array('last30', 'last60', 'last90', 'last6mth', 'lastyr', 'overayr');
$avgrating = array('4ormore', '3ormore', '2ormore', '1ormore');
$genre = array('action', 'animation', 'kids', 'comedy', 'docu', 'drama', 'horror', 'musical', 'scifi', 'thriller');
echo '<select name="genre">';
foreach($rlsdate as $date) {
echo '<option value=' . $date . '</option>';
}
echo '</select>';
echo '<select name="avgrating">';
foreach($avgrating as $arating) {
echo '<option value=' . $arating . '</option>';
}
echo '</select>';
echo '<select name="genre">';
foreach($genre as $genreItem) {
echo '<option value=' . $genreitem . '</option>';
}
echo '</select>';
?>
Code: Select all
<?php
$rlsdate = array('last30', 'last60', 'last90', 'last6mth', 'lastyr', 'overayr');
$avgrating = array('4ormore', '3ormore', '2ormore', '1ormore');
$genre = array('action', 'animation', 'kids', 'comedy', 'docu', 'drama', 'horror', 'musical', 'scifi', 'thriller');
echo '<form>';
echo '<select name="genre">';
foreach($rlsdate as $date) {
echo '<option value=' . $date . '</option>';
}
echo '</select>';
echo '<select name="avgrating">';
foreach($avgrating as $arating) {
echo '<option value=' . $arating . '</option>';
}
echo '</select>';
echo '<select name="genre">';
foreach($genre as $genreItem) {
echo '<option value=' . $genreItem . '</option>';
}
echo '</select>';
echo '</form>';
?>Code: Select all
<form><select name="genre"><option value=last30</option><option value=last60</option><option value=last90</option><option value=last6mth</option><option value=lastyr</option><option value=overayr</option></select><select name="avgrating"><option value=4ormore</option><option value=3ormore</option><option value=2ormore</option><option value=1ormore</option></select><select name="genre"><option value=action</option><option value=animation</option><option value=kids</option><option value=comedy</option><option value=docu</option><option value=drama</option><option value=horror</option><option value=musical</option><option value=scifi</option><option value=thriller</option></select></form>