CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Get the value of the selected data in database (http://www.codingforums.com/showthread.php?t=281627)

TLWH05 11-09-2012 05:21 AM

Get the value of the selected data in database
 
"Help!"
"I'm a newbie...be gentle"

I have 2 php files: (1) videolist.php (2) watch.php

My problem is i need to run the "watch.php" and post also the title of the video as caption when the title of the video was clicked.

Here's my code "videolist.php":

Code:

<?php
$con = mysql_connect("localhost","usergtf","TLWH05");
        if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }
        mysql_select_db("dbgtf", $con);
        $result = mysql_query("SELECT * FROM tblvideos");
        ?>

<table border="0" bordercolor="#FFFFFF" cellpadding="5" cellspacing="0" align="center">
        <tr id="tableheader" align="left" height="30">
            <th width="10" style="display:none">ID</th>
            <th width="80">DATE</th>
            <th width="200">TIME</th>
            <th width="350">TITLE</th>
        </tr>

<?php
        echo "<tr align='left' height='30' bgColor='#69F'>";
        echo "<td>" . $row['DATE'] . "</td>";
        echo "<td>" . $row['SERVICE'] . "</td>";
        echo "<td>" . $row['TITLE'] . "</td>";
        echo "</tr>";
}
        mysql_close($con);

?>
</table>


Redcoder 11-09-2012 08:22 PM

You cannot run two scripts at the same time for the same header request from the user.


But for this, you can have each videos having a unique ID which AUTO INCREMENTs. Then have something like a GET variable. I hope that you know how to pass and extract GET variables from the url.

So each time you fetch the video title, you also fetch the video ID.

So something like this for your above code

PHP Code:

<?php
    
echo "<tr align='left' height='30' bgColor='#69F'>";
    echo 
"<td>" $row['DATE'] . "</td>";
    echo 
"<td>" $row['SERVICE'] . "</td>";
    echo 
"<a href='watch.php?id={$row['id']}'<td>" $row['TITLE'] . "</td>";
    echo 
"</tr>";



All times are GMT +1. The time now is 09:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.