Several Newbie Qustions

Codes here !

Moderators: egami, macek, gesf

Post Reply
User avatar
Fife Club
New php-forum User
New php-forum User
Posts: 15
Joined: Wed Oct 09, 2002 7:50 pm
Location: Charlotte, NC, USA

Wed Oct 09, 2002 8:29 pm

First things first. This site is a great resource. Glad I found it. :D

Now some background. Like most of the people posting questions, I'm very new to both php and mySQL. I'm only stumbling thru all this stuff because of one database I wanted online. After just a few days screwing around with online tutorials I've got two 'experimental' weboutput pages. (straight forward) (trying some sorting)

Now I've got a few general quetions that will hopefully lead me in the right direction of where to look for more indepth details...

1. If you click the 2nd link above (the sortable one), you'll notice that whenever you chose a column to sort, it always puts the "blank" one's on top. Under the blank entries everything else ends up in the correct order. How can I sort my data but prevent the blanks from being on the top?

2a. I have 174 rows of data, each one is a person with info about them. I have all this info in one table. I look at how other scripts do similar displays and they often have limited info on the main listing page, but if you click on a link you go to another page that displays all of the full data associated with that one person. In general concept terms (not getting into specific coding just yet) how is this done? Is this simply linking to a second php page designed to display that one person's data? Or is it all in one big complicated php page.

2b. Also when looking at how other scripts do this, I see that these other scripts span their data over many different tables. Why? Is this necessary or can I just have all my data in one table?

3. If you look at either link above, both are "display all" with "sort by lastname". It looks okay at first but if you go down to the "Z's" you'll see there are 11 extra results below Z (somehow in alphabetical order from that point on). What's going on here? One clue is that those 11 rows are the same ones that I needed to edit due to complications when creating my table, but I don't know why they're sorting differently.



Wed Oct 09, 2002 11:53 pm

1: blanc entry's always turn up on top of the list, that's caused by the sort method (less means higher). You could leave those entry's completely of the list.

2a:depens on how you want to code. can be on the same script, but can also be a separate file. Easyiest is to link to another php-page wich fetches the rest of the details of the person.

2b: some browsers will only start showing a table when the got the entire table. When the page is big it will take some to before the browser shows something when using a slow connection.
Another thing is that when using one big table the width of you're cells has to be adjusted to fit each row. you're table may end up more readable when you got some empty cells.

3:When I look at the source code I can see that each field has a leading space in front of the actual data. The ones you edited don't.
space comes before other characters when you sort.

Greetz Daan


Thu Oct 10, 2002 1:23 am

A word of advice first, used   for an empty space, it'll make your table look neater
eg <td></td> => <td>&nbsp;</td>

1. Using the above code may sort out that problem! Or if you're accessing your data from a database, you can structure your query to sort it out!

2a. This works by using two pages. One lists all the data for everyone (well, the data you want, name or whatever). It also provides a link for more details about that person (ie info.php?id=230) which is generated according to something unique about that person (id or whatever). The second page will use the $_GET['id'] value to work out who to display info for, will fetch the info and display it

2b. Basically a table is rendered once the full code for it has been recieved, which is why it's preferable because as the page loads it can render the tables (a common mistake is to put the whole page in a giant table, which means whatever you do, nothing will load until the whole outer table loads fully). You can do it either way, but if you use one table, and you've got one cell which is exceptionally large, it'll increase the length of all the cells down the column.

Post Reply