Forum Moderators: coopster
<?php
$i=0;
$sql="select * from software";
$result=mysql_query($sql) or die(Error);
while($row=mysql_fetch_array($result))
{
if($i%3==0)
{
echo "</tr><tr>";
}
?>
<img src="folder1/subfolder/<?php echo $row['sub_category'];?>/Software/preview/<?php echo $row['cat'];?>/<?php echo $row['previewfile'];?>"height="170" width="150"/>
<a href="folder/subfolder/<?php echo $row['sub_category'];?>/Software/<?php echo $row['cat'];?>/<?php echo $row['file'];?>"><?php echo $row['title'];?></a> [edited by: eelixduppy at 2:32 pm (utc) on Apr 12, 2012]
[edit reason] no personal URLs, please [/edit]
<a href="folder/subfolder/subcategory/Software/category/file.pdf">title goes here</a>
<img src="folder1/subfolder/<?php echo $row['sub_category'];?>/Software/preview/<?php echo $row['cat'];?>/<?php echo $row['previewfile'];?>"height="170" width="150"/>
<a href="folder/subfolder/<?php echo $row['sub_category'];?>/Software/<?php echo $row['cat'];?>/<?php echo $row['file'];?>?fileid=<?php echo $row['id']; ?>"><?php echo $row['title'];?></a>
//then on the "final download page, get the fileid and use it to query you db
if(isset($_REQUEST['linkid']) && !empty($_REQUEST['linkid']))
{
//query mysql
}
else
{
//handle error
}
<a href="folder/subfolder/<?php echo $row['sub_category'];?>/Software/<?php echo $row['cat'];?>/<?php echo $row['file'];?>?sub_category=<?php echo $row['sub_category']; ?>&cat=<?php echo $row['cat']; ?>&file=<?php echo $row['file']; ?>"><?php echo $row['title'];?></a>
//then on the "final download page, get the variables and use them to query you db
if(isset($_REQUEST['file']) && !empty($_REQUEST['file']))
{
//query mysql
//then build the click here to start your download link
}
else
{
//handle error
}
eelixduppy,
Yes my html looks like -
<a href="folder/subfolder/subcategory/Software/category/file.pdf">title goes here</a>
After interpreted by php .and my file is stored in the location described by <a ref=""> link.
And yes i want final download page to fetch this content and offer it to download to the user?
//Render this link for them to click and go straight to your final download page.
<a href="finaldownloadpage.php?link=upload/1/<?php echo $row['sub_category'];?>/Software/<?php echo $row['cat'];?>/<?php echo $row['file'];?>">CLICK HERE</a>
//then on the final download page, get the link and offer it to download
if(isset($_REQUEST['link']) && !1empty($_REQUEST['link']))
{ ?>
<a href="upload/1/<?php echo $row['sub_category'];?>/Software/<?php echo $row['cat'];?>/<?php echo $row['file'];?>">Click here to start your download</a>
<?php } else { //error } ?>
$i=0;
// note: you should probably use pagination here
$sql = "select * from software";
$result = mysql_query($sql) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
if($i++%3==0)
echo "</tr><tr>";
echo '<td>';
printf('<img src="image.php?pid=%s" height="170" width="150"/>', $row['pid']);
printf('<a href="product.php?pid=$s">CLICK HERE</a>', $row['pid'];
echo '</td>';
}
//assert pid is an integer
if(!preg_match('/^[0-9]+$/',$_GET['pid'])) {
echo 'Must have integer pid!';
exit;
}
// select info from database
$link = mysql_connect('..','..','..');
$query = sprintf("SELECT * FROM software WHERE pid = %s", $pid);
$result = mysql_query($query) or die(mysql_error());
if($row = mysql_fetch_array($result)) {
// print all the product information, including...
printf('<a href="download.php?pid=%s">Download!</a>', $pid);
}
mysql_close($link);
// look up data in database using $_GET['pid']
// as in previous example
// this data should include where to find the image/download
// content on your box, lets say this gets set as...
$image_location = $row['previewimage'];
header("Content-Type: image/jpeg");
header("Content-Length: " .(string)(filesize($image_location)) );
echo file_get_contents($image_location);
printf(
'<a href="finaldownload.php?sub_category=%scat=%sfile=%spreviewfile=%s">CLICK HERE</a>',
urlencode($row['sub_category'),
urlencode($row['cat']),
urlencode($row['file']),
urlencode($row['previewfile'])
);
$ad_placement = 4; // starts at 0
$i = 0;
while($row = mysql_fetch_array($result)) {
if($i % 3 == 0) {
// print end/begin row
}
if($i == $ad_placement) {
// print ad
continue;
}
//print your other stuff
}
$i++;
$ad_placement = 5;
if($i % $ad_placement == 0) {