I have a dynamic table and as it builds the users flags/tick what they have done with each row of data. In one of the columns I have completed as the status. Once the user has ticked completed the information does not need to be shown in the table only the ones that are not complete. Is there a way to hide the data from the table?

"visibility:hidden" will hide the data but the row is still there. Need to hide the row.

smitho

04-10-2008, 07:44 AM

Worked out:

{echo "style=\"display:none\"";}will do the trick just need to work out how to turn it off and on.

Might try and check box or button but need it to stay set so if you refresh the page it does not turn off.

student101

04-11-2008, 07:38 AM

You should add that or this in the CSS

.posthide {
display:none
}
.postshow {
display:inline
}

<tr if ($rowlist['complete']=='Y') class="posthide">

Cheers

smitho

04-13-2008, 02:28 PM

Got this working with a button but I found a little problem. I'm using pages to navigate through the table as it gets bigger and bigger. What I found was that when the display:none is active all that happened is the row disappears but the table length stays the same.

A quick test I did with 8 entries in the database I set 2 to be completed. I set the max row display for each page to 6 so this meant I had 6 on my first page and 2 on the second. When I hit the button to hide the 2 complete rows I still have 2 pages. 5 on the first page and 1 on the second.

Could this because of the way I created the paging? Should display:none take it out of the list and only so me one page?

student101

04-13-2008, 05:23 PM

Post your code.

smitho

04-14-2008, 12:21 AM

Here's the code I've adapted to davidj's examples that way anyone who has gone through his tuts can use this code as well.

The only thing you'll need to do is add another field to the users table called showhide and set it to a varchar (4).

Rather than use completed as my flag in database table1 field2 has a number of values set to 0. The show/hide button will flag them as green when show is active and then hide then when you click hide.

Just realized the example I posted was one after using dreamweavers auto paging. This one has been cut down. I've added the show/hide button. After seeing the link to the paging tut I'm wondering if I would be able to tie in the filter with the paging. Currently if you apply a filter the table it will work but as soon as you fit the next page link the filter is lost.

$currentPage=$_SERVER['PHP_SELF']; //set the current Page this way so that you can use this with any page

$maxRows = 5; //to change the number of rows displayed set 5 to any number you wish
$noRows = 0; //this is our starting row number
if (isset($_GET['noRows'])) { //if if a page link is hit get increase the $noRow by either + or - $maxRows
$noRows = $_GET['noRows'];
}

$all = mysql_query($allrows); //because we have a limit set the query we need to set another query to determine the number of rows in our database.
$totalRows = mysql_num_rows($all);
$totalPages = ceil($totalRows/$maxRows)-1; //now that me now the number we can determine the number of pages -1 to get the last page.
$lastPage = $totalPages * $maxRows; //to get the last page as a row figure we multiple totalpages by the maxrows.

Which tutorial is this?
I only now found the arrays tutorial and Davidj never mentioned it once.

Cheers

smitho

04-14-2008, 11:47 AM

If you go to :

http://www.dreamweaverclub.com/vtm/php-mysql-apache.php

and watch "PHP, A Beginners Guide"

Part9 , 10 and 11.

you'll get the base for what I've put here. I like using this as an example to build on and test.

Cheers.

student101

04-14-2008, 12:00 PM

Cool, thanks.

I'll check it out to understand what you need better.

Cheers

smitho

04-15-2008, 03:27 AM

Although the show/hide button looks nice I don't thinks it's going to work. What I'm after is a filter effect that stays set even when you refresh the page, go to the next page or even go to another page and back.

So I'm think what I might try and do is capture the filter text output and store them in an array. Make a new column under the users table called filter and insert the filter options there. That way when the user comes back and if they have filtered the list a certain way it will apply it according to their options.

I've created the filter column in the users table.

Using this code I capture way is in the filter fields and update the database:

Now I've used serialize because if I don't I get Array as the return for $disrow['filter']. Unserializing it does not seem to work. What I'm expecting is a result like to print_r($options);

Any suggestions?

smitho

04-15-2008, 06:12 AM

Ok this is almost complete. If someone could help me with combining the paging an filter that would be great.

Just to make it clear the way I got the filter to work was to capture what the user types in the filter field and then update the users database 'filter' column with their entry. This means the list will stick with their filter until they click the clear button which will remove the data from the 'filter' column.

I was trying to find a way to add the filter request that the user typed in to a session or cookie etc but every time the page was reset the filter was lost. If anyone can tell me if this is possible that would be great. This was the only way I could get it to work. I also left the show/hide button in if anyone was interested.

$currentPage=$_SERVER['PHP_SELF']; //set the current Page this way so that you can use this with any page

$maxRows = 5; //to change the number of rows displayed set 5 to any number you wish
$noRows = 0; //this is our starting row number
if (isset($_GET['noRows'])) { //if if a page link is hit get increase the $noRow by either + or - $maxRows
$noRows = $_GET['noRows'];
}

$all = mysql_query($allrows); //because we have a limit set the query we need to set another query to determine the number of rows in our database.
$totalRows = mysql_num_rows($all);
$totalPages = ceil($totalRows/$maxRows)-1; //now that me now the number we can determine the number of pages -1 to get the last page.
$lastPage = $totalPages * $maxRows; //to get the last page as a row figure we multiple totalpages by the maxrows.

$all = mysql_query($allrows); //because we have a limit set the query we need to set another query to determine the number of rows in our database.
$totalRows = mysql_num_rows($all);
$totalPages = ceil($totalRows/$maxRows)-1; //now that me now the number we can determine the number of pages -1 to get the last page.
$lastPage = $totalPages * $maxRows; //to get the last page as a row figure we multiple totalpages by the maxrows.

Due to the LIMIT $noRows, $maxRows (to set the table rows 5 deep) what happens is the paging counts all the rows, so if the filter finds 8 entries but the database has 18 entries all up the paging works to the 18 not the 8. Should be able to nut it out but is any can point it out faster that would be great.