Forums

PHP

This topic is locked

hyperlinks in search results

Posted 11 Jul 2007 03:33:22
1
has voted
11 Jul 2007 03:33:22 Cynthia Taylor posted:
Hello - I am using Dreamweaver, php, MySQL, and PhpMyAdmin. I am trying to make a search page about books, with a results page. On the results page, I need the titles of the books that will display to be hyperlinks, which will lead to other static pages I already created about the particular book that was clicked. Is there a way I can make the book titles on the results page hyperlinks to these other pages?

I also want little pictures of the book covers to display in the search results page, which I have finally figured-out how to do. However, is there a way I could also make them links to the static book pages as well, such as image maps or something?

Thanks!

Replies

Replied 11 Jul 2007 09:50:49
11 Jul 2007 09:50:49 Steve Fuller replied:
Hi!

Without seeing your code, its hard to tell what you're doing but maybe this will help. In DW, when you have the results page open, you can add hyperlinks by selecting the dynamic text or image you want to be able to click on and set a link for it in the properties area. But to do anything more than passing a variable to another dynamic page, would cause you to have the static link you set earlier to be active in every record of your repeating region. So if you want to change that, you might use an if/else statement or other means to determine what is in the recordset and where it should link to. If you db is pretty big you could run into trouble as well. Post your code and I will try to help if I can!

See ya!
Replied 12 Jul 2007 07:34:43
12 Jul 2007 07:34:43 Cynthia Taylor replied:
Dear Steve,

I truly appreciate your help! I have been trying to make this work, but I am not a programmer, yet I still need to get this going on a website as soon as I can. I will try to include the code here that I have. This is sort of a test page to try and get everything working. I am trying to do a search page, yet I need the search results to display the title of the book as a hyperlink, so that it can go to a static page that is already created which is a book review. I also want a small image to display near the title. However, the path of the image seems to be appearing in the results section, and not the image itself. I have quite a few fields of information about each book entered into my MySQL database, including the URL of each book's page, but for now I am just trying to create a search by the book titles. I'm sorry this is hard to explain clearly in words, but I'm trying. I am also going to try to include a link in here to another site, which shows almost exactly what I am trying to produce in my site. I'm sorry it took me so long to reply to this, but I was not able to respond to your post immediately. Thank you again for any assistance you might be able to give me; I have tried so hard to figure this out with no luck!

www.kidscanpress.com/kidscanpress/KidsCanPress_3/us_version/KCP/f_home.htm

<pre id=code><font face=courier size=2 id=code> &lt;?php require_once('Connections/Books_Conn.php'); ?&gt;
&lt;?php
$colname_Recordset1 = "1";
if (isset($_POST['TitleSearch'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST['TitleSearch'] : addslashes($_POST['TitleSearch']);
}
mysql_select_db($database_Books_Conn, $Books_Conn);
$query_Recordset1 = sprintf("SELECT Title, Images FROM Reviews WHERE Title LIKE '%%%s%%' ORDER BY Title ASC", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Books_Conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt;Enter the title of the book that you would like to search for:&lt;/p&gt;
&lt;form name="Title" id="Title" method="post" action=""&gt;
&lt;input name="TitleSearch" type="text" id="TitleSearch" /&gt;
&lt;input type="submit" name="Submit" value="Submit" /&gt;
&lt;/form&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;

&lt;?php if ($totalRows_Recordset1 &gt; 0) { // Show if recordset not empty ?&gt;
&lt;table border="1" cellpadding="5" cellspacing="5"&gt;
&lt;tr&gt;
&lt;td&gt;Title&lt;/td&gt;
&lt;td&gt;Images&lt;/td&gt;
&lt;/tr&gt;
&lt;?php do { ?&gt;
&lt;tr&gt;
&lt;td&gt;&lt;?php echo $row_Recordset1['Title']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $row_Recordset1['Images']; ?&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?&gt;
&lt;/table&gt;
&lt;?php } // Show if recordset not empty ?&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
mysql_free_result($Recordset1);
?&gt;
</font id=code></pre id=code>
Replied 12 Jul 2007 07:45:10
12 Jul 2007 07:45:10 Cynthia Taylor replied:
I forgot to mention in my last post that with the link submitted as a sample of what I am trying to create, once you go to that webpage, you might have to click on the catalog search in the upper left area. Also, I have included in the MySQL database a field called Images, and in there I put the paths of those images, which I believe is what is showing up in my search results area. Thanks again!
Replied 12 Jul 2007 10:02:33
12 Jul 2007 10:02:33 Steve Fuller replied:
Hi Cynthia,

You could add a field in the db for the book review page in the table containing your books. Then when you build a detail page for the book's
details to be displayed in, you would simply add a little text with the link embedded in the href. Check the snippet below:

<pre id=code><font face=courier size=2 id=code>
&lt;p&gt;a href="&lt;?php echo $row_bookdetails['reviewURL']; ?&gt;"&gt;Click here to read a review!&lt;/a&gt;&lt;/p&gt;
</font id=code></pre id=code>


To make the links to click for detail pages for the images and text, compare the to repeat regions. First is yours, then mine but modified. Have a look for the differences:

<pre id=code><font face=courier size=2 id=code>
&lt;?php if ($totalRows_Recordset1 &gt; 0) { // Show if recordset not empty ?&gt;
&lt;table border="1" cellpadding="5" cellspacing="5"&gt;
&lt;tr&gt;
&lt;td&gt;Title&lt;/td&gt;
&lt;td&gt;Images&lt;/td&gt;
&lt;/tr&gt;
&lt;?php do { ?&gt;
&lt;tr&gt;
&lt;td&gt;&lt;?php echo $row_Recordset1['Title']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $row_Recordset1['Images']; ?&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?&gt;
&lt;/table&gt;
&lt;?php } // Show if recordset not empty ?&gt;
</font id=code></pre id=code>

Now for the mods:

<pre id=code><font face=courier size=2 id=code>
&lt;?php if ($totalRows_Recordset1 &gt; 0) { // Show if recordset not empty ?&gt;
&lt;table border="1" cellpadding="5" cellspacing="5"&gt;
&lt;tr&gt;
&lt;td&gt;Title&lt;/td&gt;
&lt;td&gt;Images&lt;/td&gt;
&lt;/tr&gt;
&lt;?php do { ?&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="details.php?bookid=&lt;?php echo $row_Recordset1['BookID']; ?&gt;"&gt;&lt;?php echo $row_Recordset1['Title']; ?&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="details.php?bookid="&gt;&lt;?php echo $row_Recordset1['Images']; ?&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?&gt;
&lt;/table&gt;
&lt;?php } // Show if recordset not empty ?&gt;
</font id=code></pre id=code>

Then on the details page, add the following snippet at the top to "catch" the variable.
<pre id=code><font face=courier size=2 id=code>
$bookid = $_GET['bookid'];
</font id=code></pre id=code>

Now create a recordset a recordset on the detail pages for displaying your info "WHERE books.bookid=$bookid" and you should be in business!
Let me know it goes for you!
Replied 12 Jul 2007 10:07:10
12 Jul 2007 10:07:10 Steve Fuller replied:
Oops, left out one of the detail hyperlinks...

<pre id=code><font face=courier size=2 id=code>
&lt;td&gt;&lt;a href="details.php?bookid=&lt;?php echo $row_Recordset1['BookID']; ?&gt;"&gt;&lt;?php echo $row_Recordset1['Title']; ?&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="details.php?bookid=&lt;?php echo $row_Recordset1['BookID']; ?&gt;"&gt;&lt;?php echo $row_Recordset1['Images']; ?&gt;&lt;/a&gt;&lt;/td&gt;
</font id=code></pre id=code>

Sorry!
Replied 13 Jul 2007 02:27:56
13 Jul 2007 02:27:56 Cynthia Taylor replied:
Hi Steve,

Thank you so much for what you have done! I am trying to implement the modifications that you have suggested, but unfortunately now I am having trouble with this forum, and so I cannot see all of the text. Would you possibly have any suggestions for that? I am not able to see all of our messages or the code you supplied because there are ads or something on the right side of this forum and the right edges of our messages are hidden beneath them. I don't know if it's a CSS thing or whatever, but it prevents me from seeing your entire postings. It doesn't do this on all of the other people's postings, but it is doing it to mine. I'm not sure what to do now. I am trying to get as far as I can with what you told me so far, at least as much as I can make out here. Please let me know if you have any ideas. Thank you again so much! I have tried to get help with this from various places because it is very important to me, and so far you are the only one that has offered to help me - thanks!
Replied 13 Jul 2007 08:04:05
13 Jul 2007 08:04:05 Steve Fuller replied:
Hi Cynthia,

I have the same thing happening on my machine. Just copy and paste the forum entry into notepad for viewing! I had figured that this
forum had more activity than this, but I don't see it! I have a problem myself and could use a little help but I haven't found any place that
really responds to the more advanced issues. I have a shopping cart that has a bug and I can't find any help with it! Anyway, I have printed the last few
entries into a pdf that you can get here:

www.redhousewebdesign.com/cynthia_taylor.pdf

That's my site, btw. I will be adding tutorials and stuff as I am able to do so. No time right now, though. Check it out and let me know what you think!
Replied 14 Jul 2007 05:25:57
14 Jul 2007 05:25:57 Cynthia Taylor replied:
Hi Steve,

Thanks for your help again! I started working with what you told me, but I guess I still don't have it right because it doesn't all work for me. I think I am getting confused as to what goes where and on what pages. I know, I guess I'm getting a little frazzled and overwhelmed with it all. Anyway, I still greatly appreciate what you've done for me, and at least you gave me something to work with, as I am still going to do. Unfortunately, I won't have time to do anything with it for the next few days, but I will get back at it after that. Thank you for making that PDF available to me, and I almost wish I could email you directly as this is very annoying not seeing all of the text in here. You have a very smart looking website, I truly like it very much! I would talk about it a little more with you, but I don't think I should be going off of topic in here. However, I will say that it appears you're using Access 2007 and I am also interested in that; I just read a help book about it. I'm sorry you are having troubles of your own with the shopping cart. I never created one or I would try to help you if I could. Is there something different you could use? If I can help you, maybe by trying to research it or something, just let me know and I'll be glad to try. Good-luck with it, and thank you again - you are the only one that has offered to help me!

Cynthia
Replied 14 Jul 2007 05:52:13
14 Jul 2007 05:52:13 Steve Fuller replied:
Hi Cynthia,

I am sorry you're still having problems! You can contact me directly at my site thru the contact form. I agree about off topicness here but I thought this forum gets more traffic than it does. So I don't know if anybody would notice! Feel free to get a hold of me thru my site. Your few days away is actually good. I will be finished with the shopping cart over the weekend come hell or high water, so once that is done, I can help you achieve the functionality you desire. I am glad you like my site! I do simple access apps for people needing a smarter way to work with their data if their db is not online! If their db is on line, its mysql and php all the way. Although I do dig Coldfusion because of how simple it is. PHP is a true programming languange where Coldfusion is a markup language like html. So you have to close tags like in html. Like so:

<pre id=code><font face=courier size=2 id=code>
&lt;cf_Query&gt;
&lt;/cf_Query&gt;
</font id=code></pre id=code>.

But since it is a markup language, its easier to learn than say learning php, java or C++. But hosting is expensive and everyone wants to say its a dead language. But adobe runs their website in Coldfusion! A .cfm page extension will give it away when you're on a CF site. Shopping carts are easier than people think! But I have a custom cart that is doing things most standard carts won't do. I had to hand code that. I used some webassist extensions as well but some of that is too complicated for mere mortals. Thanks for all the nices things you have said! Contact me whenever you like!

Cheers,
Steve
Replied 14 Jul 2007 06:39:00
14 Jul 2007 06:39:00 Cynthia Taylor replied:
Steve,

I attempted to send you an email - thanks!


Cynthia

Reply to this topic