-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
I thought the names in the db were stored as
name_one etc..
So doing implode(' ,',str_replace('_',' ',($fieldArr))) will look for the word as name one not name_one
-
The first three loops (in the array) are returning no rows, so their is no song called that for the first three.
-
add
echo mysql_num_rows($result);
under the query and tell us what it says
-
That if statement won't work because if the query fails the or die will kick in and end the script.
-
Ok try putting it in the second foreach loop, although your code and structure don't make much sense
-
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>
-
Ok, in the for loop shouldn't you be echoing $fieldArr2
-
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.
-
Does it work?
-
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
-
Where are you printing it out, or where are you getting a problem
-
try it
-
yes in the sql LIMIT 10
-
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.
-
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");
-
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.
-
Have you tried doing
print_r(str_replace('_',' ',$fieldArr));
Check if everything is as it should be, try applying it before the loop
-
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
-
use something like mysql_fetch_assoc(); to get the data in the rows
-
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); } } } ?>
-
First off that was a rhetorical question and second off did you read the last bit of my reply.
-
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
-
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']);
-
add error_reporting(E_ALL); to the top before session_start();
are their any errors?
Problem with session
in PHP Coding Help
Posted
PHP version might be different