conditional display
Posted: Mon Jun 29, 2009 9:10 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi all,
again great help this site has been so far.
I need some help in a display page on my site.
Currently I have some code that calls back all of the data from a table in my sql database and is displayed in alternating row colours.
What I am looking to do is to have a selection box above this code that say you can select the year from it will then change the sql statement to have a "Where" statement in it. Is it possible to do this with the user selecting the option in the dropdown box and then it changes automatically and not have to press a submit button?
the current code I have to display ALL data is as follows:
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi all,
again great help this site has been so far.
I need some help in a display page on my site.
Currently I have some code that calls back all of the data from a table in my sql database and is displayed in alternating row colours.
What I am looking to do is to have a selection box above this code that say you can select the year from it will then change the sql statement to have a "Where" statement in it. Is it possible to do this with the user selecting the option in the dropdown box and then it changes automatically and not have to press a submit button?
the current code I have to display ALL data is as follows:
Code: Select all
<?php
include 'dbc.php';
$sql="SELECT * FROM fixtures ORDER BY year,month,date ASC";
$result=mysql_query($sql);
?>
<table width="100%">
<tr>
<td class="rowQ" width="10%">Year</td>
<td class="rowQ" width="10%">Month</td>
<td class="rowQ" width="10%">Date</td>
<td class="rowQ" width="10%">Day</td>
<td class="rowQ" width="10%">Fixture</td>
<td class="rowQ" width="30%">Venue</td>
<td class="rowQ" width="10%">Results</td>
<td class="rowQ" width="10%">Type</td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
if($color==1){
echo "<tr class='rowA'>
<td>$rows[year]</td>
<td>$rows[month]</td>
<td>$rows[date]</td>
<td>$rows[day]</td>
<td>$rows[fixture]</td>
<td>$rows[venue]</td>
<td>$rows[results]</td>
<td>$rows[type]</td>
</tr>";
$color="2";
} else {
echo "<tr class='rowB'>
<td>$rows[year]</td>
<td>$rows[month]</td>
<td>$rows[date]</td>
<td>$rows[day]</td>
<td>$rows[fixture]</td>
<td>$rows[venue]</td>
<td>$rows[results]</td>
<td>$rows[type]</td>
</tr>";
$color="1";
}
}
mysql_close();
?>
</table>