Thought this was easy? Exclude rows from being displayed
Moderator: General Moderators
-
motleycrewl
- Forum Newbie
- Posts: 8
- Joined: Tue Mar 04, 2008 2:16 pm
Thought this was easy? Exclude rows from being displayed
I'm having a hard time finding a way to exclude certain rows from being displayed in my table. Im making a simple table for hours of shops. If the shops have no entry for "friday" (friday hours) then I DONT want that row to be shown in the table, but if there is data there, then i want a new row to be shown. That might not have made too much since but below is my code:
$sql = "SELECT Name, open, close, weekday, openf, closef, friday FROM hoursfood ORDER BY Name";
$dbq = mysql_query($sql,$dbh);
echo "<TABLE align = center class=hours frame = hsides rules = rows cellpadding = 10>";
while ($row = mysql_fetch_array($dbq)) {
echo "<TR>";
echo "<TD class=padded-hours align=left>".$row{'Name'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'open'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'close'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'weekday'}."</TD>";
echo "</TR>";
// Below is the code i want to execute only if there is data in the 'friday' row
echo "<TR>";
echo "<TD class=padded-hours align=center>";"</TD>";
echo "<TD class=padded-hours align=center>".$row{'openf'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'closef'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'friday'}."</TD>";
echo "</TR>";
}
echo "</TABLE>";
mysql_close($dbh);
Any help would be very appreciated. Thanks in advance
$sql = "SELECT Name, open, close, weekday, openf, closef, friday FROM hoursfood ORDER BY Name";
$dbq = mysql_query($sql,$dbh);
echo "<TABLE align = center class=hours frame = hsides rules = rows cellpadding = 10>";
while ($row = mysql_fetch_array($dbq)) {
echo "<TR>";
echo "<TD class=padded-hours align=left>".$row{'Name'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'open'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'close'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'weekday'}."</TD>";
echo "</TR>";
// Below is the code i want to execute only if there is data in the 'friday' row
echo "<TR>";
echo "<TD class=padded-hours align=center>";"</TD>";
echo "<TD class=padded-hours align=center>".$row{'openf'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'closef'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'friday'}."</TD>";
echo "</TR>";
}
echo "</TABLE>";
mysql_close($dbh);
Any help would be very appreciated. Thanks in advance
Re: Thought this was easy? Exclude rows from being displayed
Code: Select all
$sql = "SELECT Name, open, close, weekday, openf, closef, friday FROM hoursfood WHERE friday IS NOT NULL ORDER BY Name";
-
motleycrewl
- Forum Newbie
- Posts: 8
- Joined: Tue Mar 04, 2008 2:16 pm
Re: Thought this was easy? Exclude rows from being displayed
Thanks, but I dont think that worked.
I guess its ok if the row's where 'friday' is null is called but I just dont want them displayed in the table.
Right now they just show up as blank rows in my table. How do i get rid of those?
I guess its ok if the row's where 'friday' is null is called but I just dont want them displayed in the table.
Right now they just show up as blank rows in my table. How do i get rid of those?
Re: Thought this was easy? Exclude rows from being displayed
ok keep your original SELECT
like that? Or do I still misunderstand :S
Code: Select all
echo "<TABLE align = center class=hours frame = hsides rules = rows cellpadding = 10>";
while ($row = mysql_fetch_array($dbq)) {
echo "<TR>";
echo "<TD class=padded-hours align=left>".$row{'Name'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'open'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'close'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'weekday'}."</TD>";
echo "</TR>";
// Below is the code i want to execute only if there is data in the 'friday' row
if($row{'friday'} != "")
{
echo "<TR>";
echo "<TD class=padded-hours align=center>";"</TD>";
echo "<TD class=padded-hours align=center>".$row{'openf'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'closef'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'friday'}."</TD>";
echo "</TR>";
}
-
motleycrewl
- Forum Newbie
- Posts: 8
- Joined: Tue Mar 04, 2008 2:16 pm
Re: Thought this was easy? Exclude rows from being displayed
Shoot, it seems like that should work.
Here is the site: http://universitycenters.ucsd.edu/new2/index.php
If you scroll to the food-hours section you can see what im talking about: a bunch of extra <td>'s with no data to fill them because they are calling the "friday" data (which I want to leave out of the table construction)
Thanks for answering by the way!! Do you have any other ideas?
Here is the site: http://universitycenters.ucsd.edu/new2/index.php
If you scroll to the food-hours section you can see what im talking about: a bunch of extra <td>'s with no data to fill them because they are calling the "friday" data (which I want to leave out of the table construction)
Thanks for answering by the way!! Do you have any other ideas?
Re: Thought this was easy? Exclude rows from being displayed
sorry, think it was my mistake.
do this:
lets cross our fingers
do this:
Code: Select all
$sql = "SELECT Name, open, close, weekday, openf, closef, friday FROM hoursfood ORDER BY Name";
$dbq = mysql_query($sql,$dbh);
echo "<TABLE align = center class=hours frame = hsides rules = rows cellpadding = 10>";
while ($row = mysql_fetch_array($dbq)) {
if($row{'friday'} == "")
{
echo "<TR>";
echo "<TD class=padded-hours align=left>".$row{'Name'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'open'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'close'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'weekday'}."</TD>";
echo "</TR>";
}
else
{
// Below is the code i want to execute only if there is data in the 'friday' row
echo "<TR>";
echo "<TD class=padded-hours align=center>";"</TD>";
echo "<TD class=padded-hours align=center>".$row{'openf'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'closef'}."</TD>";
echo "<TD class=padded-hours align=center>".$row{'friday'}."</TD>";
echo "</TR>";
}
-
motleycrewl
- Forum Newbie
- Posts: 8
- Joined: Tue Mar 04, 2008 2:16 pm
Re: Thought this was easy? Exclude rows from being displayed
Well Ill be, it worked. You are a saint my friend. Thank you so much. until next time
Re: Thought this was easy? Exclude rows from being displayed
really? When I look you have the same issue 