Re: Noob question: Making search results clickable.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 18, 2009 at 03:04:13PM +0000, Paul Jinks wrote:

> Hi all
> 
> I'm building a fairly basic php/mySql site but I'm running into
> problems due to my total lack of experience. I have a database of
> videos - each has a title, transcript, description and one or more
> topics. So far I can search the database by topic (using a drop-down
> menu), like this:
> 
> <?php
> $result = mysql_query("SELECT title FROM videos WHERE topic1= '$topic'");
> 
> while($row = mysql_fetch_array($result))
>   {
>   echo $row['title'];
>   echo "<br />";
>   }
> ?>
> 
> Basic, but it works. What I'd like now is to make the search results
> clickable so clicking them leads to a page showing all the details of
> that video. I have a page "video_display.php" set up, ready to display
> the details from the database, but how do I connect the two?

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>";

Then ensure that video_display.php is set up to fetch the video whose ID
is passed to it via the GET parameter.

All this assumes I understood what you're getting at. Which is
questionable. ;-}

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux