PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<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>";
}
?>
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
<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>";
}
?>
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'm not sure I understand what you want to do. $link is a PHP variable, by the time the user sees the page and can click on anything, the PHP is finished, so it cannot possibly react to a click. What are you trying to achieve? Wouldn't a simple hyperlink do what you want?