I don't know the best way to title this question but am trying to accomplish the following goal:
When a client logs into their profile, they are presented with a link to download data from an existing database in CSV format. The process works, however, I would like for this data to be 'fresh' each time they click the link so my plan was - once a user has clicked the link and downloaded the CSV file, the database table would 'erase' all of its data and start fresh (be empty) until the next set of data populated it.
My EXISTING CSV creation code:
<?php
$host = 'localhost';
$user = 'username';
$pass = 'password';
$db = 'database';
$table = 'tablename';
$file = 'export';
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field'].", ";
$i++;
}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= '"'.$rowr[$j].'",';
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
any ideas?
I'm playing around with NHibernate 3.0. So far things are pretty cool. I'm trying to attach an entity that wasn't detached previously:
var post = new Post(){ Id = 2 }
session.Update(post); // Thought this would work but it doesn't.
post.Title = "New Title After Update";
session.Flush();
Is this possible so that only Title gets updated? This is currently possible in EntityFramework. I'd like to not have to load Post from the database when I just need to update a few properties.
I'm running two load balanced servers for one website, and I'd like the databases to be synchronized. Queries may be run on either of the two servers because they are both production sites, so the replication can't just work one way.
It doesn't have to be in real-time, just fairly accurate so people don't notice adifference when they get switched to a different server.
hi, i have 2 object: user, group that have a relationship many to many
i want create a user and associate some groups to it.
How can i do it?
thanks
I've tried with this. but it's wrong:
user = new User();
List<int> gruppi = new List<int>() {1,2};
utente.Group =db.Group.Where(p => gruppi.Contains(p.GruppoID)
When i dump a table with uppercase letters using mysqldump it comes out as lower case in my dump.sql file. I found a report here in 2006, almost 4 years old http://bugs.mysql.com/bug.php?id=19967
A solution here suggest making linux insensitive. I rather not if possible. Whats the easiest way to copy a win32 db into linux?
Is it possible to add a method to an array() in javascript? (I know about prototypes, but I don't want to add a method to every array, just one in particular).
The reason I want to do this is because I have the following code
function drawChart()
{
//...
return [list of important vars]
}
function updateChart(importantVars)
{
//...
}
var importantVars = drawChart();
updateChart(importantVars);
And I want to be able to do something like this instead:
var chart = drawChart();<br>
chart.redraw();
I was hoping there was a way I could just attacha method to what i'm returning in drawChart(). Any way to do that?
I have a function used on the datepicker to limit dates selected to the first of the month... I invoke it by setting a class and listener, such as:
$( ".datepickfom" ).datepicker(
{
beforeShowDay: fom,
showOn: "both",
buttonImage: "/images/calendar.png",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: "m/d/yy",
yearRange: "-25:+100",
constrainInput: true
}
);
the fom call:
function fom(date){
if (date.getDate() != 1) {
return [false, "", "Specify 1st of Month"];
}
return [true, ""];
}
This works great for regular forms.
I'm looking to extend this functionality to the HandsOnTable 'date' cell data types.
var $container_1 = $("#datatable_1");
var handsontable_1 = $container_1.data('handsontable');
$("#datatable_1").handsontable(
{ columns: [
{},
{},
{
type: 'date',
dateFormat: 'm/d/yy'
},
{},
{
type: 'dropdown',
source: ["","Y","N"]
},
{},
{}
]
});
This also works as it should, but the date lets me pick other dates besides the first.
Is there a way to attach the
beforeShowDay
option to the HOT cell call as well?
I'm trying to extract andrestorea Security Descriptor of a NTFS file, via Windows API - XP SP3, I'm trying to understand which functions are actually able to do it properly, but I simply fail.
I found this Remark over MSDN:
http://msdn.microsoft.com/en-us/library/aa379573%28VS.85%29.aspx
"Some SECURITY_INFORMATION members work only with the SetNamedSecurityInfo function. These members are not returned in the structure returned by other security functions such as GetNamedSecurityInfo..."
"Some members..."
Which members? Why?
"Other Security functions such as..."
Which functions? Why?
Anybody have any experience with extracting and restoring a security descriptor of a NTFS file?
Thanks in advance,
Doori Bar
I was reading on how Activities communicate and how the calls stack up on top of each other. But at any instant when the OS(or dalvik) is low on resources, it can choose to kill Paused or Stopped Activities. In this scenario, how do we restore previous state of the activity(in which it was before getting killed) when we reach the same activity on our way back.
Does stack store the state as well as references to the Activity? Aren't their chances of achieving a different state when we re-constuct activity (onCreate)?
If e.g. I keep control markup in DB instead of ascx file.
How can I load control from string constant?
(of course if I don't want to save copy to disk)
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
I have a table with
name varchar
address varchar
country varchar
city varchar
.....
to store address of location
example:
name|address|country
HaLong hotel|156 blahblah street|Vietnam
Hotel Ha Long|156 blah blah|Vietnam
Two rows above is duplicate data.
I have a form, when user submit new location. The code need to find akin records to give a message (ex: This location already in db, use it or create new?)
How to make a query to get akin record like this?
I have custom control - chart with size, for example, 300x300 pixels and more than one million points (maybe less) in it. And its clear that now he works very slowly. I am searching for algoritm which will show only few points with minimal visual difference.
I have link to component which have functionallity exactly what i need
(2 million points demo):
http://www.mindscape.co.nz/demo/SilverlightElements/demopage.html#/ChartOverviewPage
I will be grateful for any matherials, links or thoughts how to realize such functionallity.
Hi,
In My application as the user opens the camera, camera should capture a image as soon as there is adifference in image when compared to previous image and camera should always be in capturing mode.
This should be done automatically without any user interaction.Please Help me out as i couldn't find the solution asap.
Thanks,
ravi
When I right click on "databases" in Sql Server 2005 Management Studio
and then Attach... Add I get the following error:
C:\Documents and
Settings\Administrator\My
Documents\SQL Server Management
Studio\
Projects\Path\To\MDF\And\LDF\Files\
cannot access the specified path or
file on the server. Verify that you
have the necessary security privileges
and that the path or file exists.
The answer is easy - the MDF and LDF files where removed when Nant (by way of my dev
machine) issued a drop command.
But, after replacing the MDF and LDF files, I want to reattach the database but the
above error keeps coming up when I select "Add".
Also, I have already "unattached" the database in question and it no longer appears on
the left under "databases".
I have tried to replace a copy of the MDF and LDF files in the folder being referenced
and that didn't work.
Any ideas as to how to gracefully get rid of this error?
Hi there,
What's the differencebetween using the two options below to output link HTML?
theme('links', $primary_links, array('class' => 'links primary-links'))
theme_links($primary_links, $attributes = array('class' => 'links primary-links'))
Many thanks
Hi,
The same compiled .Net / C++ / Com program does different things on two seemingly same computers. Both have DOZENS of things installed on them. I would like to figure out what the differencebetween the two is by looking at an ASCII diff. Before that I need to "serialize" the list of installed things in a plain readable format - sorted alphabetically + one item per line.
A Python script would be ideal, but I also have Perl, PowerShell installed.
Thank you.
The answer in this post http://stackoverflow.com/questions/2119680/use-jquery-to-check-if-a-url-on-another-domain-is-404-or-not shows how to use YQL in Jquery to check if URL is valid or not. However, I can't get this to work for me. The only difference I can think of is that my URL is a text file (http://mycrossdomain.com/sometext.txt) and not HTML.I think the YQL query needs to be adjusted accordingly. Any help is appreciated.
I have a file of data Dump, in with different timestamped data available, I get the time from timestamp and sleep my c thread for that time. But the problem is that The actual time difference is 10 second and the data which I receive at the receiving end is almost 14, 15 second delay. I am using window OS. Kindly guide me.
Sorry for my week English.
Hi,
I need to get all dates and people modifications to currenlty displayed page, all changes which have been published and end user can see differencebetween them.
My page is aspx connected to pageLayout in which is richhtmlfield with article.
How to do that? Is it possible to do that ?
Here is what happened,
i ve installed xubuntu via wubi on my D: drive. I have 2 drives by the way C: and D:
Basically i use C: drive for windows and D drive for rest andbackup as everybody does. And i installed my WUBI installation on drive D: too.
Than i tried to do a little extreme thing. Which is basically i tried to make a shortcut to D: folder within Xubuntu. The problem is suddenly all my files disappeared. Folders stayed same, but files disappeared. Also the drive have the files, i know because it is still full, but the thing is i cannot see any of my files.
I tried checking for errors and some basic data recovery which didn't worked at all
Any help?
Perl 6 seems to have an explosion of equality operators. What is =:=? What's the differencebetween leg and cmp? Or eqv and ===?
Does anyone have a good summary?