Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. Ok try putting it in the second foreach loop, although your code and structure don't make much sense
  2. 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>
  3. Ok, in the for loop shouldn't you be echoing $fieldArr2
  4. Hmm, i am not sure why not unless it is something to do with the fact you are using do while loop which isn't needed.
  5. Does it work?
  6. So it is like red green red green etc. If so then one way could be $i = 0; while(looping stuff) { if($i == 1){ echo "red"; $i = 0; } elseif($i == 0) {echo "green"; $i = 1; } } sorry bout the code in a rush
  7. Where are you printing it out, or where are you getting a problem
  8. yes in the sql LIMIT 10
  9. And is that what the row names should be after the str_replace? if so it works, and you are doing something wrong somewhere else.
  10. then do $ID= 1; $higherposition= mysql_query("SELECT position FROM table WHERE id = ($ID+1) ORDER BY DESC LIMIT 1,1"); $lowerposition= mysql_query("SELECT position FROM table WHERE id = ($ID-1) ORDER BY DESC LIMIT 1,1");
  11. CURL, but you should know that websites are pretty open source so the code will be hard to stop the owners redistributing it and/or removing any validation code.
  12. Have you tried doing print_r(str_replace('_',' ',$fieldArr)); Check if everything is as it should be, try applying it before the loop
  13. erm... Probably just the forums i go on, but based on the design and "coolness" of the site i have to say the Microsoft site for Microsoft Surface
  14. use something like mysql_fetch_assoc(); to get the data in the rows
  15. 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); } } } ?>
  16. First off that was a rhetorical question and second off did you read the last bit of my reply.
  17. O, i didn't see the custom keys, just modify mine by removing the counter and the $i var and replace the $i in the echo with the key name
  18. 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']);
  19. add error_reporting(E_ALL); to the top before session_start(); are their any errors?
  20. What are you expecting it to echo exactly? That is just the query to select the rows, once selected they need to be retrieved.
  21. Show the insertion code and where you are using the str_replace
  22. Lol ,that is what Ajax is used for to run php pages on the server.
  23. Ahh my bad, just googled it should be ini_get('session.save_path');
×
×
  • 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.