Advertisement
Advertisement
| 03.27.2008 at 05:43PM PDT, ID: 23276159 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 03.27.2008 at 09:59PM PDT, ID: 21228135 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: |
<?php
/*/-------------------------------------------------------------------\
| Original Name : csvview.php |
| Author : Neil Maskell |
| Function : Reads a specified CSV file (Comma seperated) and |
| converts it into a readable HTML table. |
| |
| You could set up a html form with an input field |
| called filename. Then use csvview.php as the action. |
| |
| the reason cache is being disabled is because if you |
| update the csv file the cache doesnt realise and shows|
| an older version of the information. |
| |
| The CSV files should (and normally are) in the format:|
| field1,field2,filed3,filed4 |
| field1,field2,field3,field4 |
\-------------------------------------------------------------------/
*/
//
$filename = ""; // File to open. quote out this variable if you are using a form to link to this script.
/*
No cache!!
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
/*
End of No cache
*/
function viewlog($filename) {
$fp = fopen($filename,"r");
$file = fread($fp,65535);
$replaced = eregi_replace(",", "<td>", $file);
$replaced2 = eregi_replace("\n", "<tr><td>", $replaced);
$replaced3 = eregi_replace("\r", "<tr><td>", $replaced2);
fclose($fp);
return $replaced3;
}
echo "<html><head><base href=\"./\"><title>CSV File Viewer</title></head><body bgcolor=silver>";
// Start the table definition of your choice
echo "<table border=0 bordercolor=black cellspacing=0 cellpadding=5 width=100% style='font-size:10pt'>";
echo viewlog($filename);
echo "</table></body></html>";
exit;
?>
|
| 03.27.2008 at 10:00PM PDT, ID: 21228139 |
| 03.28.2008 at 04:36AM PDT, ID: 21229402 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: |
<?php
if (isset($_REQUEST['submit'])) {
if (array_key_exists('data', $_REQUEST)) {
$tempfile = tempnam('/tmp', 'csv');
file_put_contents($tempfile, $_REQUEST['data']); //Stick data in a temp file
$fp = fopen($tempfile, 'r'); //Reopen it so we can use fgetcsv
ini_set('auto_detect_line_endings', true);
//Connect to DB
$db = mysql_connect('localhost', 'id', 'pass');
mysql_select_db('mydb', $db);
$values = array();
while (($row = fgetcsv($fp, 1000, ',')) !== false) {
if (!is_null($row[0])) { //Skip blank lines
$values[] = '('.mysql_real_escape_string($row[0]).','.mysql_real_escape_string($row[1]).','.mysql_real_escape_string($row[2]).')';
}
}
if (count($values) > 0) {
$query = "INSERT INTO mytable (field1, field2, field3) VALUES ";
$query .= implode(',', $values);
var_dump($query);
mysql_query($query) || die(mysql_error());
}
fclose($fp);
unlink($tempfile); //Delete temp file
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>CSV</title>
</head>
<body>
<form action="" method="post">
<textarea name="data" rows="20" cols="50">
</textarea><br />
<input name="submit" type="submit" value="Submit" />
</form>
</body>
</html>
|
| 03.28.2008 at 04:37AM PDT, ID: 21229409 |