Forums
This topic is locked
Making mysql search results into hyperlinks
Posted 26 Nov 2004 16:00:26
1
has voted
26 Nov 2004 16:00:26 Simon Wantling posted:
Hi,Could someone help me please. I am redesigning my website, to which I've added a mysql database which stores species of insects. In dreamweaver I have successfully connected to the database and can retrieve data and display it on the screen. Could someone possible tell me how I would go about making the individual results into active links to another pages of my website. Hope someone can help as I'm getting a bit lost at the moment !
Thanks
Simon
Replies
Replied 26 Nov 2004 16:24:14
26 Nov 2004 16:24:14 Simon Martin replied:
Hi Simon,
You can use the Go To Detail page server behaviour from DMX.
Select your dynamic text and then use the behaviour.
The detail page will show the full details for the insect selected, so you need to pass to that page the ID value for the link (probably the species_id). So where it says Pass URL parameter: enter something like spe_id (something you'll remember the other side of this process). In the recordset make sure its selected the recordset that you are using to create your links and finally the column should be the primary key for that table (i'm guessing species_id)
What that does is to give your results a hyperlink that passes a name (spe_id) and to that it adds a value which is the primary key from the database so you will have something like
<a href="results.asp?spe_id=89>
and the spe_id will change for each item because its picking up its value dynamically.
Next you need to build the 2nd page (results.asp)
There you will need to make a recordset that gets all the details you need from the table and filter it (if you're using the simple dialogue) using the spe_id = the URL parameter. So it will get only the results where the species_id is = to that you selected in the 1st page.
There is a tutorial in DMX if you get stuck (press F1 and look up detail pages / master detail pages)
Or post up here for some more tips
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
You can use the Go To Detail page server behaviour from DMX.
Select your dynamic text and then use the behaviour.
The detail page will show the full details for the insect selected, so you need to pass to that page the ID value for the link (probably the species_id). So where it says Pass URL parameter: enter something like spe_id (something you'll remember the other side of this process). In the recordset make sure its selected the recordset that you are using to create your links and finally the column should be the primary key for that table (i'm guessing species_id)
What that does is to give your results a hyperlink that passes a name (spe_id) and to that it adds a value which is the primary key from the database so you will have something like
<a href="results.asp?spe_id=89>
and the spe_id will change for each item because its picking up its value dynamically.
Next you need to build the 2nd page (results.asp)
There you will need to make a recordset that gets all the details you need from the table and filter it (if you're using the simple dialogue) using the spe_id = the URL parameter. So it will get only the results where the species_id is = to that you selected in the 1st page.
There is a tutorial in DMX if you get stuck (press F1 and look up detail pages / master detail pages)
Or post up here for some more tips
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 26 Nov 2004 20:31:03
26 Nov 2004 20:31:03 Simon Wantling replied:
Thanks Simon,
I have my individual species pages already made. Will this method allow me to link individual species results to their relevent pages. For instance, if the user types in yellow, they might get a result like;
Yellow Horned
Yellow Tail.
Would the above method alllow me to have a different link for each species html page.
Sorry for all the questions, but I'm completely new to PHP, hence thats why I decided on using Dreamweaver for the dynamics of the site.
Thanks
Simon
I have my individual species pages already made. Will this method allow me to link individual species results to their relevent pages. For instance, if the user types in yellow, they might get a result like;
Yellow Horned
Yellow Tail.
Would the above method alllow me to have a different link for each species html page.
Sorry for all the questions, but I'm completely new to PHP, hence thats why I decided on using Dreamweaver for the dynamics of the site.
Thanks
Simon
Replied 27 Nov 2004 02:10:49
27 Nov 2004 02:10:49 Simon Martin replied:
Hi Simon,
The technique I've outlined creates a basic master detail set up; typically the master page lists your categories (of insects) and links from that master page take you to a detail page - which has the complete info you want to show.
The advantage to this approach is that you only need to create 2 pages, they call their data dynamically from your database. This cuts down the amount of work you'll have to do. If, for instance, you wanted to add another 50 species you would add them to your database and the 2 page set up would dynamically take care of the rest for you (much quicker than manually creating all those new html pages)
You can select the results from the master page in a number of ways; you could simply have a text list of species (method i've described already), a graphic for each species as a link, a drop down (or combination of drop downs) to select criteria, or you could have a text box to enter a key word.
The basic principle is the same in all these methods. The user passes some selection criteria to the database which then returns results that match, and you display them on the 2nd page.
All your information can then be dynamic, text and images, so you wont need your hardcoded individual species pages.
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
The technique I've outlined creates a basic master detail set up; typically the master page lists your categories (of insects) and links from that master page take you to a detail page - which has the complete info you want to show.
The advantage to this approach is that you only need to create 2 pages, they call their data dynamically from your database. This cuts down the amount of work you'll have to do. If, for instance, you wanted to add another 50 species you would add them to your database and the 2 page set up would dynamically take care of the rest for you (much quicker than manually creating all those new html pages)
You can select the results from the master page in a number of ways; you could simply have a text list of species (method i've described already), a graphic for each species as a link, a drop down (or combination of drop downs) to select criteria, or you could have a text box to enter a key word.
The basic principle is the same in all these methods. The user passes some selection criteria to the database which then returns results that match, and you display them on the 2nd page.
All your information can then be dynamic, text and images, so you wont need your hardcoded individual species pages.
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 27 Nov 2004 08:59:34
27 Nov 2004 08:59:34 Simon Wantling replied:
Hi Simon,
Thanks for your reply. I see your point. Although I have about 150 pages already created for the species details. It looks like in the long run it would be well worth me changing to a database containing their info. I did set up a set page with your recommendations and I have to say it worked a treat and much less work. One problem I did have was displaying the image. This just showed as a load off garbage text and special characters. The text info was fine except that. Have you any ideas what might be happening there? I'm not sure whether I have the mysql database set up right.
Thanks
Simon
Thanks for your reply. I see your point. Although I have about 150 pages already created for the species details. It looks like in the long run it would be well worth me changing to a database containing their info. I did set up a set page with your recommendations and I have to say it worked a treat and much less work. One problem I did have was displaying the image. This just showed as a load off garbage text and special characters. The text info was fine except that. Have you any ideas what might be happening there? I'm not sure whether I have the mysql database set up right.
Thanks
Simon
Replied 27 Nov 2004 22:24:08
27 Nov 2004 22:24:08 Simon Martin replied:
Hi Simon, glad to hear its making sense to you - often that's the hardest part...
There are 2 methods for using a database to handle images for a webpage. You can have the database store the images as BLOBS (binary large objects) which will make your database quite big quite quickly or....
The other method (which I think 95% of people use) is to store the file name of the image in the database; with or without the path. You can then use this to provide the src attribute for your image, and because its in the recordset you return its simply a case of selecting the "Data sources" radio button when you want to use an image to pick it up.
I mentioned you could store the image name with or without the path, if you store the full path to the image (e.g. images/ant.jpg) and later decide to move your images folder that can cause problems. The alternative is simply to store the image name (ant.jpg) but when you are selecting the src you hardcode images/ before the dynamic bit
src="images/<%=rsSpecies("image""%> rather than simply src="<%=rsSpecies("image"%>"
personally i'd probably go with the full path in the database option as the chances of you moving everything around is quite low - I've mentioned it to give you the option
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
There are 2 methods for using a database to handle images for a webpage. You can have the database store the images as BLOBS (binary large objects) which will make your database quite big quite quickly or....
The other method (which I think 95% of people use) is to store the file name of the image in the database; with or without the path. You can then use this to provide the src attribute for your image, and because its in the recordset you return its simply a case of selecting the "Data sources" radio button when you want to use an image to pick it up.
I mentioned you could store the image name with or without the path, if you store the full path to the image (e.g. images/ant.jpg) and later decide to move your images folder that can cause problems. The alternative is simply to store the image name (ant.jpg) but when you are selecting the src you hardcode images/ before the dynamic bit
src="images/<%=rsSpecies("image""%> rather than simply src="<%=rsSpecies("image"%>"
personally i'd probably go with the full path in the database option as the chances of you moving everything around is quite low - I've mentioned it to give you the option
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]