PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a table of results pulled from a mysql database which is printed to html using the code below. I now want to add hyperlinks to each record for taking the visitor to the details page of each record. I guess its a case of adding another table to the database containing the hyperlinks with matching ids, but i have no idea how to go about writing the php code for it. Please advise.
Below is the structure of dvd_titles. I do not yet have a table for the details pages, they are still being created, but i want to start testing links to them. I suspect the table will have dvd_id and url columns.
Field Type Null Default
dvd_id int(11) No 0
dvd_title varchar(200) No
prodn_year year(4) Yes NULL
dvd_rlsdate date Yes NULL
Indexes:
Keyname Type Cardinality Field
PRIMARY PRIMARY 33 dvd_id
dvd_title
Space usage:
Type Usage
Data 16,384 B
Index 0 B
Total 16,384 B
Row Statistics:
Statements Value
Format dynamic
Rows 33
Row length ø 496
Row size ø 496 B
Creation Dec 17, 2006 at 12:52 AM
I dont want to echo 'show details'. I want the table of results as it is now, but each title in the 'Title' result column i want as a link to its relevant details page.
The table produced from the sql query within the php looks like this:
Title Rating DVD Release Date
"title1" 5.0 20 Nov 06
"title2 5.0 27 Nov 06
"title3" 4.3 27 Nov 06
"title4" 4.0 30 Oct 06
"title5" 4.0 06 Nov 06
"title6" 4.0 13 Nov 06
"title7" 3.7 30 Oct 06
"title8" 3.6 04 Dec 06
"title9" 3.6 11 Dec 06
"title10" 3.4 16 Oct 06
Baring in mind this table of results will change every week as the database is updated. Please advise what the exact href php code needs to look like and where i should insert it into my current code.
You are already looping through your data, you are already outputting the database fields. Study your code carefully and you should be able to apply what we've mentioned easily.
Thanks for the feedback. I tried your code, but i get the error: 'query dvd_id is ambiguous', so i added the tablename to the query on the first line making 'dvd_titles.dvd_id'. Then i get another error: 'Fatal error: Call to undefined function: htmlentities()'
The table border is printed, but no table content.