|
Table Built from PHP |
Onewing
Member #6,152
August 2005
|
html, php and a little javascript. There, now you know the extent of my web building knowledge. Don't want to read my ramblings? Then go to the bottom of the post! Anyway, I'm working on making my website (seems I almost never have time to). I've got all my games listed, ranging from ideas to completed to dead on my harddrive. Each game has a small, one paragraph description and a screenshot, plus a few button-slash-links for a spot on forums, a download, etc. Know, you put all of these sections on one page and you have a lot of scrolling to do. So, my idea was to put a table (literally) of contents at the top, with a hop link to the given game. The table is built from php code that looks up a database storing information about the games. The table includes several things like what version, if it has a download, what I used to make it and so on. You can click the column title at the top of the table to rebuild the table sorted on that column. I realized this was bloated so I'm creating a condensed version which only has the most important information. I also want to work on coloring the rows. Like, every other row when it is sorted by title and maybe color it by blocks when sorted by anything else. Ultimately, this might be really slow, since when you click on a column header to rearrange the table, the entire page has to be regenerated (including the lengthy set of sections below). I suppose I could use a frame (or maybe an iframe?), but I'm not sure if that is a good route to take. My question is, is building a table using PHP a good idea? Moreover, is it an acceptable coding practice or am I just abusing the concept of PHP here. Remember what I said at the beginning and my lack of web-building knowledge; I come up with ideas that I think are good but might have problems that my limited knowledge doesn't foresee. ------------ |
X-G
Member #856
December 2000
|
It's a good idea, it's appropriate use of PHP, and it's recommended. -- |
mEmO
Member #1,124
March 2001
|
I don't see how it is different than generating the rest of the page with PHP. In short, yes, it's a good idea. [edit] Blasted, I need to stop reading other forums while posting. --------------------------------------------- |
Onewing
Member #6,152
August 2005
|
Thanks! Quote: I don't see how it is different than generating the rest of the page with PHP. This might be my biggest concern. The page itself is rather lengthy, and since the table is going to be sorted by whatever column header they click and the whole page is rebuilt, instead of just the table. I might be able to use iframe though, which was an idea I had writing the above post. I'll have to experiment with it. ------------ |
Inphernic
Member #1,111
March 2001
|
Quote: Ultimately, this might be really slow, since when you click on a column header to rearrange the table, the entire page has to be regenerated (including the lengthy set of sections below). I suppose I could use a frame (or maybe an iframe?), but I'm not sure if that is a good route to take. Or you could use JavaScript to provide real-time sorting, falling back to regeneration where applicable. -- |
BAF
Member #2,981
December 2002
|
Unless you have tons (and I mean tons) of data, it should't cause that much of a performance hit to reorder and regenerate the whole page. |
Crazy Photon
Member #2,588
July 2002
|
And don't forget to not use tables for the layout, just for data. This website illustrates what I mean, and also has a lot of useful guidelines to build the web page. ----- |
bamccaig
Member #7,536
July 2006
|
I wonder how JavaScript would perform sorting the data itself. It would be nice, but I bet you'd be left writing your own sorting functions (or finding some prewritten ones on the Web). Instead of using an iframe you could put the heading-table on it's own page, like a table of contents, and link to a genaric script, passing the record's primary key in the querystring, that displays a single item's information at a time or; if the average item has relatively little information, link to an anchor target on a paged list of content. Using the count of records in the database, determine which page each item would appear on (using the number of items displayed on a page and the total count) and embed a variable in the querystring like page=x in the linked address so when you load the generic script (php), it would load the xth page of data. For example: SELECT * FROM MyTable LIMIT 0, 20; I'm not entirely sure on the SQL or the DBMS you are using so you'll have to look put the syntax appropriate to your tools. I believe that says return all columns from MyTable beginning at record 0 (the first one) and only return 20 rows. The next page might (guessing) look like this: SELECT * FROM MyTable LIMIT 20, 20; Then, the address for the item whose primary key was 23 and was displayed on page 2 might look like this (assuming localhost was instead your domain name/IP address): http://localhost.com/item.php?id=23&page=2 These are my ideas. It might complicate things paging via unique sorting mechanisms because you would likely want the item.php page sorted the same way as your table of contents, which would alter the page a particular item was displayed on and the order the items were displayed on that page. Since the table of contents is separated from the main data it wouldn't be a problem regenerating the data, and therefore, recalculating this information whenever the sorting techique is changed. Then pass that as well via the querystring, for example: http://localhost.com/item.php?id=23&page=2&sort=2 I would generally stay away from frames because they don't flow nicely with Web browsers, being that each frame can refresh separately, etc. It's inconsistent and a frustrating experience for the user trying to navigate, IMHO. I wouldn't shy away from using tables to layout your Web pages though. Browser wars are bad enough on PCs, let alone trying to make your site compatible with portable devices, etc. If your page is professional and has the intent of marketing your skills or is used for commercial purposes, target your sites compatability for the most exposure possible. Otherwise, target your intended audience or provide general browser support (IE/Firefox). Web development tools are poorly designed and inconsistently supported. Personally, I hate today's Web languages and as a single example want to replace everything SGML based with something more programmer-friendly. I'm no fan of <anything that="looks" like="this" />. I am devising a replacement for Web development that I can only describe as an extensible, byte-coded, C-like language with explicitly defined static-typing, manual memory management (and out of scope backup garbage collection), and graphical concepts derived from full fledged 2D/3D graphic libraries, as well as Flash... It would be rendered in a single official 'browser' , or by a virtual machine or run-time. It would need a standard framework for defining common Web/GUI controls, graphical elements, and animation concepts; as well as for data management and access. From there you could extend it as required, and possibly implement binary libary concepts, etc. There would hopefully be an official IDE designed for it's development with graphical support and debugging, as well as optimizers, and automatically tracked application versioning for update management and ultimately, when you 'installed' an application the client's browser, virtual machine, or run-time would compile it natively for better performance... Don't hold your breath. (Sorry for expressing that off-topic idea) (I don't have time to revise this so hopefully it's not too confusingly written) -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Tobias Dammers
Member #2,604
August 2002
|
Quote: Personally, I hate today's Web languages and as a single example want to replace everything SGML based with something more programmer-friendly. I'm no fan of <anything that="looks" like="this" />. I am devising a replacement for Web development that I can only describe as an extensible, byte-coded, C-like language with explicitly defined static-typing, manual memory management (and out of scope backup garbage collection), and graphical concepts derived from full fledged 2D/3D graphic libraries, as well as Flash... It would be rendered in a single official 'browser' , or by a virtual machine or run-time. It would need a standard framework for defining common Web/GUI controls, graphical elements, and animation concepts; as well as for data management and access. From there you could extend it as required, and possibly implement binary libary concepts, etc. There would hopefully be an official IDE designed for it's development with graphical support and debugging, as well as optimizers, and automatically tracked application versioning for update management and ultimately, when you 'installed' an application the client's browser, virtual machine, or run-time would compile it natively for better performance... You mean, the worst of all common programming languages and web technologies, combined into one massive package? Good idea. Quote: I wonder how JavaScript would perform sorting the data itself. It would be nice, but I bet you'd be left writing your own sorting functions (or finding some prewritten ones on the Web).
Took me 10 seconds to google this. Quote: I wouldn't shy away from using tables to layout your Web pages though. Browser wars are bad enough on PCs, let alone trying to make your site compatible with portable devices, etc. If your page is professional and has the intent of marketing your skills or is used for commercial purposes, target your sites compatability for the most exposure possible. Otherwise, target your intended audience or provide general browser support (IE/Firefox). Web development tools are poorly designed and inconsistently supported.
IE != general browser support. --- |
Mark Oates
Member #1,146
March 2001
|
php good. dynamically generated webpages good. -- |
CGamesPlay
Member #2,559
July 2002
|
Quote: Personally, I hate today's Web languages and as a single example want to replace everything SGML based with something more programmer-friendly. I'm no fan of <anything that="looks" like="this" />. I am devising a replacement for Web development that I can only describe as an extensible, byte-coded, C-like language with explicitly defined static-typing, manual memory management (and out of scope backup garbage collection), and graphical concepts derived from full fledged 2D/3D graphic libraries, as well as Flash... It would be rendered in a single official 'browser' , or by a virtual machine or run-time. It would need a standard framework for defining common Web/GUI controls, graphical elements, and animation concepts; as well as for data management and access. From there you could extend it as required, and possibly implement binary libary concepts, etc. There would hopefully be an official IDE designed for it's development with graphical support and debugging, as well as optimizers, and automatically tracked application versioning for update management and ultimately, when you 'installed' an application the client's browser, virtual machine, or run-time would compile it natively for better performance... Haha! Buddy, it's Active X! [edit] -- Ryan Patterson - <http://cgamesplay.com/> |
bamccaig
Member #7,536
July 2006
|
Tobias Dammers said: You mean, the worst of all common programming languages and web technologies, combined into one massive package? Good idea. What did I mention that you consider bad to have in a development package? I don't claim to know enough to develop it. I just dream of something powerful and done right. The definition is constantly evolving. Tobias Dammers said: Javascript performance, of course, hugely depends on the client machine; since Array.sort() is a core language feature, I'd expect most implementations to use fairly efficient code. I guess I wasn't trying very hard. Developing in JavaScript on a regular basis I've learned not to get my hopes up. Besides, Array.sort() appears to sort a single Array (which is like a single column). I don't have time to look very hard (I'm at work), but http://w3schools.com doesn't seem to say anything about sorting an entire table of data. In other words, storing a table worth of information in JavaScript (however you go about it) and trying to sort it all based on a single column doesn't seem easy. Again, I'm not able to spend much time looking though. http://w3schools.com also say that sorting is done alphabetically by default so you have to create a function to sort by numbers (let alone dates, etc.). Again, I don't have time right now to figure it out (and it's JavaScript so I'm not all that excited about it anyway). Tobias Dammers said: IE != general browser support. I didn't mean that IE followed the standards. I meant that IE is one of the most popular browsers. Currently, on Allegro.cc 42% of users are running Firefox and 40% of users are running IE. The next runner up is Opera with 6%. These figures are according to A.cc. I don't know how that detection is implemented and can't guarantee it's accuracy. Still, I would expect similar results in the average user base. And the farther away from technical people and the closer your audience gets to Windows the use of IE should increase. I usually use IE in Windows and Firefox in Linux. I like them both and hate Web browsers in general. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Tobias Dammers
Member #2,604
August 2002
|
Quote: What did I mention that you consider bad to have in a development package?
Let me elaborate: All those things create this image in my mind of a huge, bloated, slow, unresponsive, useless blob occupying half my HDD just so I can view your site. No thank you. --- |
le_y_mistar
Member #8,251
January 2007
|
tables are good. php is a good RAD tool It comes down to if you can write good code to generate clean tables. ----------------- |
Tobias Dammers
Member #2,604
August 2002
|
Quote: I usually use IE in Windows and Firefox in Linux. I like them both and hate Web browsers in general. What's to like about IE? OK, it starts up a little faster than FF or Opera, but that's about it. Quote: Besides, Array.sort() appears to sort a single Array (which is like a single column). I don't have time to look very hard (I'm at work), but http://w3schools.com doesn't seem to say anything about sorting an entire table of data. In other words, storing a table worth of information in JavaScript (however you go about it) and trying to sort it all based on a single column doesn't seem easy. Again, I'm not able to spend much time looking though. http://w3schools.com also say that sorting is done alphabetically by default so you have to create a function to sort by numbers (let alone dates, etc.). Again, I don't have time right now to figure it out (and it's JavaScript so I'm not all that excited about it anyway).
Well, Javascript is "the" web scripting language, and if you don't like it, there's little you can do. You can't really feasibly write web pages in anything but HTML / XHTML, and you can't feasibly provide client-side scripts in anything but Javascript (unless you like to support ActiveX, in which case this conversation is over). Quote: tables are good. php is a good RAD tool Yes. No matter what Billy Boy is trying to teach us. --- |
Inphernic
Member #1,111
March 2001
|
Table sorting works well/fast enough to be considered for small datasets (20-50 records or so should be reasonable when considering 'any' client machine). For big datasets, page regeneration is a better option. Considering you are listing games, I'd say you're going with the small dataset scenario.. unless you plan on making 50+ versions of Toggles. Quote: php is a good RAD tool what -- |
Tobias Dammers
Member #2,604
August 2002
|
Since you have to code the page regeneration scenario anyway to support clients without javascript, I'd say try that first and see if the result is acceptable (in terms of execution speed and server load). Quote: what --- |
Inphernic
Member #1,111
March 2001
|
Quote: Either this [en.wikipedia.org] or that [rad.org.uk]. I'd say the latter, considering PHP itself isn't a RAD tool. -- |
Tobias Dammers
Member #2,604
August 2002
|
Not explicitly, no. --- |
Onewing
Member #6,152
August 2005
|
Quote: Considering you are listing games, I'd say you're going with the small dataset scenario.. unless you plan on making 50+ versions of Toggles. Good glory, don't let me get away with doing something like that. Although, I am revamping it to 2.0 with some major changes to the game mechanics (as an attempt to see if I've increased the "fun factor" of the game, something that's more difficult than optimizing and/or producing efficient algorithms). Anyway, I'm using the table-built-by-php method for several different things on the site. One, the listing of games I've worked on (which is about 20, only about 3 of which have made it through the beta stages). Two, a more detailed leader board of the top 100 highscores from Toggles (an early version of that is here and was only about ten minutes of work, obviously you can see I stole a template from OSWD). Third, a site for Invictis that I mentioned a while back and for the "cards" of the game, which is going to be a very large number, plus it will have the images for the card (FuriousOrange has made some very impressive work for this and I've been promising him a site showcasing it for forever). Thanks to all for your knowledge. Hopefully I will use it wisely. ------------ |
Ron Ofir
Member #2,357
May 2002
|
Quote: obviously you can see I stole a template from OSWD You can't steal templates from OSWD, that's what it's for! Though you could have spent one more minute to erase all irrelevant stuff. |
Onewing
Member #6,152
August 2005
|
Quote: You can't steal templates from OSWD, that's what it's for!
Quote: Though you could have spent one more minute to erase all irrelevant stuff. Actually, it would have only taken a second. But I only had five minutes, not five minutes and one second! ------------ |
Inphernic
Member #1,111
March 2001
|
Quote: It does allow for rather rapid application development though... Nah, not really. Sure, one simple site and/or garbage is fast and easy to write, but it's not that 'rapid' when you are doing something big/serious. There's something interesting on the way though when it comes to PHP..! Quote: You can't steal templates from OSWD, that's what it's for! There is a difference between 1) taking a template + attributing the actual author properly and 2) taking a template + not attributing the actual author but throwing a "CIOYRUGHT BY RON OFFIR BEST WEBS DESINGERS EVAR!?? BTW NEOPETS ROCXXXX" on it instead. -- |
Ron Ofir
Member #2,357
May 2002
|
Yup, but he did attribute the actual author properly. Anyway, Ofir is with one F!!!! AND MYSPACE PWNS NEOPETS!!!! LOLOL OMGFGFGFGFG111:P |
Inphernic
Member #1,111
March 2001
|
Quote: Yup, but he did attribute the actual author properly. Yes - after he got caught. -- |
|
|