Terminology
I’m developing a website that allows someone to input a large amount of information into a database and someone can view and sort a trimed down version on a page (view only 5 fields instead of 12). Then click on the individual items and this opens up a page that displays all the information.
I know there has to be a tutorial on how to do this somewhere. I just do not know what this is called so I’m unable to do a proper search.
Second question on indexing
How would I go about automatically assigning a database entry an index/id/whatever? I have a feeling this will be really important to be able to do the above.
Set the field to AUTO_INCREMENT when you create the database table. The identifier will be generated for you, you don’t have to assign it.
There’s really not a term for something as basic as your first question. To not show some fields, you simply don’t write code to show them. No term for not doing something.
I’ve figured that much out, but what I’m on a loss for is to be able to click on the displayed items to open up a new page that would display all of the information in an already created table.
I have the working pages for displaying a smaller amount of information for sorting and a static page for the displaying of the full info, I just don’t know how to connect the two. I know I can find the necessary tutorial on the web somewhere but I just don’t know what I should type in the search to find it.
then in the other page, you use $_GET[‘id’] in your DB query to retrieve that item
like how this forum page works; each link in the thread list includes the thread or post ID in the URL (?p=# or ?t=#), and showthread.php uses that to look up the thread in the database
What about for images? I’m guessing when uploading to use a naming convention (using the item’s id) and when displaying the item’s individual page to use that to call up the image in the same fashion as when I call up its information.
As far as associating the image with the page, you just need to store the filenames in the database. You can have a table called “images” which has two columns, “page_id” and “filename”. You insert a row for each image, with the ID of the page the image goes with and its filename.
Uploading images means you have to worry about name collision – uploading two different images with the same name. You can either generate a unique identifier for each image and use that in the filename – add a 3rd column to the images table, an AUTO_INCREMENT integer – or detect when there’s a conflict and add something to the filename then. For example, if dog.gif exists, check if dog-2.gif exists. If not, rename the new uploaded file to dog-2.gif and store that name. Continue until you find an unused number.