PDA

View Full Version : Help with updating db record


mediabob
06-18-2007, 01:21 PM
Hi, I am making a download page and I want to have a download counter with the count stored in the database. The way I have it atm is that you see a list of downloads and when you click the download button a pop up window appears with info for your download and starts the download for you.

Now what I want to happen is that when this window opens it updates the download count in the database by adding a +1 to it. I can't use the update method in DW because it requires the use of a form and I don't want the user to have to click anything in the pop up window, since the download starts automatically.

So how can I have this window automatically update? It already queries the correct table to pull info on the file.

Thanks

davidj
06-18-2007, 01:25 PM
dreamweaver written code or are you manually writing this yourself

oh and is it PHP or ASP

oh and welcome to the forum

mediabob
06-18-2007, 02:44 PM
It is 99% dreamweaver written code and it is PHP, since it is a pop up it is a relatively simple page, here is the code:

<?php require_once('Connections/dload.php'); ?>
<?php
$colname_dpage = "1";
if (isset($_GET['example'])) {
$colname_dpage = (get_magic_quotes_gpc()) ? $_GET['example'] : addslashes($_GET['example']);
}
mysql_select_db($database_dload, $dload);
$query_dpage = sprintf("SELECT eid, ename, eurl, edcount FROM example WHERE eid = %s", $colname_dpage);
$dpage = mysql_query($query_dpage, $dload) or die(mysql_error());
$row_dpage = mysql_fetch_assoc($dpage);
$totalRows_dpage = mysql_num_rows($dpage);
?>
<html>
<head>
<title>File Download</title>
<meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $row_dpage['eurl']; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {color: #ffffff}
body {
background-image: url(images/page_back.gif);
}
.style3 {color: #ffffff; font-size: 12px; }
.style4 {font-size: 16px}
-->
</style>
</head>
<body>
<table width="300" height="293" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="8" background="images/head.gif"><span class="style1">File Download </span></td>
</tr>
<tr>
<td height="141" align="center" valign="top" background="images/fp_article_back.gif"><p class="style1">Your file should begin to download shortly. If not Click Below: </p>
<p><span class="style4"><a href="<?php echo $row_dpage['eurl']; ?>">Download</a></span></p>
<p><span class="style3">By downloading this file you agree to our Terms and conditions. </span><br>
</p></td>
</tr>
<tr>
<td height="20" align="right" valign="top" background="images/blue_bar.gif"><a href="javascript:window.close()" class="style1">X Close Window</a> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($dpage);
?>

davidj
06-18-2007, 02:52 PM
sorry

i have stopped supporting DW code. Just wanted to clarify

someone may come along and help.

If you want to learn PHP then give me a shout. I help more members who write there own code because they can understand the logic therefore its easier to explain on my part.