Downloads display thing..
Hello everyone! I store my graphics in a MySQL database and this is the code I'm using to display them on my page:
$dcounter=$dcounter["dcounter"]; and $pcounter=$pcounter["pcounter"]; should count the downloads/previews and $pcounter and $dcounter should display them?
So, the problem is it won't display the number of the downloads/previews. I know I'm doing something wrong, but I don't know what.
Anyone knows?
By the way, maybe I'm doing something wrong in phpMyAdmin? Both dcounter and pcounter are set to VARCHAR(5) not null Default: 0
Hello everyone! I store my graphics in a MySQL database and this is the code I'm using to display them on my page:
PHP:
<?php
//MySQL connection variables
$user="blahblah";
$host="localhost";
$password="blahblah";
$database="blahblahblah";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
//Which mySQL table to select from and in what order
$query = "select * from `layouts` order by id desc";
$result = mysql_query($query, $connection) or die ("Could not execute query : $query ." . mysql_error());
$rows = mysql_num_rows($result);
if ($rows=="0") { echo "No layouts found."; }
//Gets and assigns variables to array
while ($row=mysql_fetch_array($result)) {
$id=$row["id"];
$title=$row["title"];
$artist=$row["artist"];
$artisturl=$row["artisturl"];
$type=$row["type"];
$size=$row["size"];
$date=$row["date"];
$previewimage=$row["previewimage"];
$download=$row["download"];
$preview=$row["preview"];
$dcounter=$dcounter["dcounter"];
$pcounter=$pcounter["pcounter"];
//Prints out results
echo "<table id=\"box_top\"><tr>
<tr><td>
<b>$title</b>
</td>
</tr>
</table>
<table id=\"box\">
<tr>
<td valign=\"top\">
<img src=\"$previewimage\" width=\"160\" height=\"110\" border=\"0\" alt=\"\">
</td>
<td valign=\"top\" width=\"170\">
<b>Added</b>: $date
<br><b>Type</b>: $type
<br><b>Size</b>: $size
<br><b>Designer</b>: <a href=\"$artisturl\" target=\"_blank\">$artist</a>
<br><b>Previews</b>: $pcounter
<br><b>Downloads</b>: $dcounter
<br><br>
<a href=\"$preview\"><b>Preview</b></a> ย <a href=\"$download\"><b>Download</b></a>
</td>
</tr>
</table><br>";
}
?>
$dcounter=$dcounter["dcounter"]; and $pcounter=$pcounter["pcounter"]; should count the downloads/previews and $pcounter and $dcounter should display them?
Anyone knows?
By the way, maybe I'm doing something wrong in phpMyAdmin? Both dcounter and pcounter are set to VARCHAR(5) not null Default: 0






