Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Posts posted by DeanWhitehouse

  1. No

     

    try

    <?php 
    $link = mysql_connect('localhost', 'MYDATABASE-USERNAME', 'MYDATABASE-PASSWORD')
    mysql_select_db('MYDATABASE-NAME') 
    ?>
    <html>
    
       <head>
          <title>Daily Pricing</title>
       </head>
    
       <body>
          <?php 
    $fieldArr = array('nav','pop','nav_change','as_of_date');
    $fieldArr2 = array(); 
    foreach($fieldArr as $fields) $fieldArr2[$fields] = array(); 
    
    $sql = mysql_query("SELECT ".implode(' ,',$fieldArr)." FROM dailypricing") or die(mysql_error());
    
    echo str_replace('_',' ',$fields);
    
    while($row = mysql_fetch_array($sql))
    
    {
        foreach($fieldArr as $f) 
       
        { 
            if(!empty($row[$f])) 
            { 
                $fieldArr2[$f][] = $row[$f]; 
            }else{ 
                $fieldArr2[$f][] = ' '; 
            }   
        } 
    }
    
    echo '<table border="1">';
    
    foreach($fieldArr as $f)
    
    { 
        echo '<tr><td>'.$f.'</td>'; 
         
        foreach($fieldArr2[$f] as $d)   
        {   
            echo '<td>'.$d.'</td>';   
        }   
        echo '</tr>';   
    }   
    echo '</table>'; 
    ?>
       </body>
    
    </html>
    

  2. That might just redirect to the file page, or it might not i am not %100.

     

    This is my code for downloading zip files.

     

    <?php
    if(isset($_GET['download']) && is_numeric($_GET['download']))
    {
    $id = $_GET['download'];
    $id = stripslashes($id);
    $sql = "SELECT * FROM djw_snippet WHERE id = ".$id;
    $sql = mysql_query($sql);
    $count = mysql_num_rows($sql);
    if($count == 0) 
    {
    	header("Location:http://djw-webdesign.awardspace.com/snippet.php");
    }
    else
    {
    	$row = mysql_fetch_assoc($sql);
    	$file = $row['file'];
    		if(!file_exists("Files/".$file))
    	{
    		$sq1 = "INSERT INTO djw_missing_file (file,ip) VALUES ('".$file."','".$_SERVER['REMOTE_ADDR']."')";
    		$sq1 = mysql_query($sq1);
    		?>
    		<script type="text/javascript">
    			alert("The file you are trying to download cannot be found. This error has been reported to an administrator.");
    		</script><noscript>
    			The file you are trying to download cannot be found. This error has been reported to an administrator.<br>
    			You will now be redirected.
    		</noscript>
    
    
    
    		<meta http-equiv="refresh" content="3;url=http://djw-webdesign.awardspace.com/snippet.php">			
    		<?php
    	}
    	else
    	{
    		$downs = $row['downloads'] + 1;
    		mysql_query("UPDATE djw_snippet SET downloads = '$downs' WHERE id = '$id'");
    		header("Pragma: public");
    		header("Expires: 0");
    		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    		header("Content-Type: application/force-download");
    		header( "Content-Disposition: attachment; filename=".basename($file));	
    		header( "Content-Description: File Transfer");
    		readfile($file);
    	}
    }	
    }
    ?>

  3. use $_GET to get the id then get the file name from the db, then send the file as a header

     

    e.g.

    $id = $_GET['id'];
    $sql = mysql_query("SELECT filename FROM table WHERE id = '".mysql_real_escape_string($id)."' LIMIT 1") or die(mysql_error());
    $sql = mysql_fetch_assoc($sql);
    header("Location:".$sql['filename']);
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.