Archive for August, 2009

ITC280 – brute-force nav page

19 August 2009

I wanted to do something special with “nav” (navigation).  The stuff on the left sidebar.

On a shopping site this usually contains a dynamically-changing set of links to help the customer find items of interest.

But that’s fancy code. I wanted something on the left that would submit specific queries of the user’s choosing. But the form of check boxes I had there, as cool as it was in its basic implementation, was not  doing what I wanted because I didn’t have time to work out all the code.

I had the form submitting the query arguments to the server in the form of a query string on the URL for the page named in the form’s “action” property, a page I called “art_choice”. This is pretty standard. But if you want the query to be reusable (in other words, the form settings to stay the same) after the first submit, you have to write extra code.  Any paging function takes the basic query and adds different limits to it as the user goes through the pages of results. Our pager had nothing built in to save a variable query statement. The query statment was fixed in the list include and would re-run every time a new page was chosen.

I looked on the net and in the text for different ways to deal with saving a variable query. I found the tech of Partial Page Rendering using inline frames and similar methods. The text goes over the use of the $_SESSION variable in PHP for this purpose. And it also mentions the simpler method of saving the data in hidden form elements.

I decided on an unconventional approach using hidden form elements arranged in a table. Each cell in the table would produce a different query result. I like the idea of “laying out all the choices” for a web user, though the concept has its limitations. I could have written code to build the table iteratively each time the page was called, but I didn’t feel like I had the time, so I just wrote out the whole table in HTML and filled each cell in with its unique query string. This works, as far as it goes, with just a little change to the “choice” page which the form buttons all call. I left in echos of some of the strings involved so I could see what was going on “behind the scenes.”  This does not include any paging – that was the basic trick. I got the query results down small enough so that none contained more than 6 records.

Total time, including study, about 5 hours.

Advertisements

ITC280 – continue re-org, upload, test

14 August 2009

I have spent roughly 10 hours since the last post getting my pages ready to upload to zephyr.

I spent a lot of time re-working the page list spreadsheet (in Open Office). I still don’t find the format totally satisfactory but it’s getting better. Where a specific include goes with a specific public page, it is listed on the same line with the page, and their purpose is described on one line. I also added a location column to keep track of paths.

I edited all my local pages for the zephyr path names. I don’t have different pages for use at home now. I just put both paths on the same page and comment the unneeded one out. Editing the paths for the Rich Text Editor is a real pain in the butt, though, and it doesn’t work yet, either at home or at school.

The first_data and admin_reset pages worked on zephyr after tweaking database names. MySQL at home seems to be set to ignore capital letters in table names (makes them small letters) so I’ll have to see if this solves anything at home with these pages.

Everything else seemed to be working, but I didn’t test uploading on zephyr, just at home, where it worked.

Also note that I don’t yet have a “contact us” form, though it is a link on my left sidebar. The right sidebar is just text at this point, while the left side is set up to send a query string to art_choice.php. This shows the top page fine, but if there are other pages they come up blank and error messages complain about a bad data array or somethnig like that.

There is a lot of code on the site now, and a lot of pages. Much of it was provided to us by Bill. I did work from home for this most recent upload and test. Zephyr is a public server and is available to anyone. The uploads require a secure FTP client (WinSCP in my case) but anyone can look at the public pages with a browser.

ITC280 – Adding more features, better org.

12 August 2009

I have not been keeping up this blog!

I have worked several hours on developing alternative search methods for large databases.  I created a database of 10,000 categories. I then created a grid – a table with 9 cells with a table with nine cells in each cell. These are to hold the category names at different levels of category in a certain pattern. I got a way of mapping the query results into the cells for controlled queries containing exactly 81 results (9×9).

Then I went back to the main application and got it fully organized and somewhat smoothed out then started working on passing query data from the left sidebar into the “list” page.

The organizing involved boiling down every public page that generates HTML (some don’t – only do redirects) into a little top section of notes and parameter selections and a little bottom section of includes.

Most of the public pages follow this exact pattern.

The path of the first include, the configuration include, has to be adjusted depending on your installation. This is a pain if you are testing the pages on more than one installation. Then the configuration file sets all the other default paths so you have to edit that file for different installations.

The connect include contains your user name and password for your database (in plain text!). This also has to be edited for each different installation (if it is different).

All the rest of the code and content generation is done in the includes (the php includes). This is a very regular pattern to adhere to.  So you do almost all you fiddling in the includes. TIME FOR CLASS!

ITC280 – boiling it down

3 August 2009

I spent a couple hours yesterday incorporating all the class features that were in my “new” pages into my “older pages. That’s mostly: list and view with paging and including database queries. Now my “original” design uses Bill’s style sheet and just has links on the nav panel, whereas the “alternate” design uses Liz Castro’s style sheet and has fancy forms in both side panels (they don’t do anything yet.)

I transferred these today to the school file server.

Next steps will include adding user-controlled queries and a secure “account logon” for purchases.

Bill is also talking about content management which is another major application of php and databases (such as on this site.)

ITC280 – versions and variables

1 August 2009

I worked probably about 4 hours today on my pages.

I thought I would be getting into fancy queries, but I discovered that I hadn’t gotten all the pages to work together properly.

Public pages:

So far the two major public pages are just lists of includes. You have to get those right.

Private (php) includes:

The includes create links back and forth between the two public pages, so you have to make sure those links are set right. I set the link value in a variable.

Versions:

On top of that I have three versions of the site (soon to become two). If one version calls a page from another version, subsequent calls will fail.

My simplest version, using little-altered code from Bill, uses a different html style than my other ones (which use tables for some formatting). So when I exported that code to my other includes, I had to add stuff to put the “view” content into a “td” (table-data) tag. Then I went back and made Bill’s page work like that, too.

Code and “print” sections:

I found it very helpful in writing my includes to put as much logic and code as possible at the top, with strings that could vary assigned to variables. Then below that I would “print out” the page by switching to html mode and just using php to echo the variables in their proper places. If you build lists using “while” this practice has to be modified, but it’s still basically useful.

I like to have color, but besides that I am not paying a lot of attention to formatting. Once I got my generated views inside proper td tags, what I saw in the browser was okay with me.