Links in php
Posted: Sun Jun 01, 2008 7:00 am
Hi,
I have some script that grabs a load of urls and titles from a database. Here is the code I am using
What I want to do is when the title is clicked it changes $link to the $url from the database and executes the function download(). The part I do not know how to do is change the $link to the $url from the database when the title is clicked
I have some script that grabs a load of urls and titles from a database. Here is the code I am using
Code: Select all
<link href="../CSS/tutlist.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function download(){
<?php
$page = "trigger.php?";
$link = "";
//redirect them to the download page :)
echo '<meta http-equiv="refresh" content="0;url=trigger.php?$link">';
?>
}
</script>
<?php
//***********************
include ("../cgi-bin/dbconnect.php");
//***********************
$sql = "select * from tutorials";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result))
{
$field1= $row["title"];
$field2= $row["description"];
$field3= $row["url"];
echo "<div class='tableText'><a href='javascript:download()' <?php $link = $field3; ?>$field1</div></a>";
echo "<div class='tableText'>$field2</div>";
}
?>