...

View Full Version : Get the value of the selected data in database



TLWH05
11-09-2012, 05:21 AM
"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":



<?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 (http://php.net/manual/en/reserved.variables.get.php) 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
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>";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum