Re: Noob question: Making search results clickable.

From: Date: Thu, 19 Nov 2009 14:53:55 +0000
Subject: Re: Noob question: Making search results clickable.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-299931@lists.php.net to get a copy of this message
On Wed, 18 Nov 2009 10:31:59 -0500, Paul M Foster wrote: > Replace your query with: > > "SELECT title, id FROM videos WHERE topid1 = '$topic'" > > or whatever index you have to select a particular video from your table. > > Replace your echo statement above with: > > echo "<a > href="video_display.php?video_id=$row[id]">$row[title]</a>"; Without actually checking, I don't think "$row[...]" is going to work in double quoted strings. I'm pretty sure it needs to be in braces. You also need to escape the double quotes and put the array indexes in single quotes: echo "<a href=\"video_display.php?video_id={$row['id']}\">{$row['title']}</a>"; Personally, I prefer something like this: $id = $row['id']; /* No urlencode(), assuming numerical id */ $title_h = htmlspecialchars ($row['title']); echo "<a href=\"video_display.php?video_id=$id\">$title_h</a>"; or (somewhat cleaner): echo <<<_ <a href="video_display.php?video_id=$id">$title_h</a> _; /Nisse

« previous php.general (#299931) next »