Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Exporting MySQL Table


Hi,

How do you export a MySQL table to a tab-delimited text file so I can put it into excel?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Exporting Mysql
there is a function in phpmyadmin that exports all the data etc from a mysql
database to an sql text document, or Excel File.

I would like to know if there is an inherent way of doing this without
phpmyadmin. - straight through php.

Exporting From MySQL To .csv Using PHP
I'm sort of new to PHP. I am using the following code to retrieve a
column from a database and to put all of the results into a .csv
file. This allows creates a .csv file, but only lists the first
result from the database. It is not returning all of the rows. I
know the issue is somewhere in my "foreach" but I'm not sure where.

<?php

$selectSql = "SELECT artist_name FROM lounge_products";
$selects = $db->getAll($selectSql);

foreach($selects as $select) {

$content = $select[artist_name].",";

}

Header("Content-Disposition: attachment; filename=export.csv");
print $content;
?>

Exporting Mysql To Csv Or Excel Via PHP
Hi, I need to know how to write a php code how to export the mysql database into CSV or Excel or ISO 20001 format. or if you know any tutorial site for it.

Exporting MySQL Database To File Using PHP
I want to export my database to a file that is hosted on the same server. I got this script from somewhere, but it doesnt work. Most likely because I cannot access mysql command thru the shell_exec() command, however, I am able to use the wget command thru the shell...

Here's the code I was trying to use:

Exporting Mysql Data To CSV In Php Code!!
how can i export the results of a query to a csv file with the columns name in the filed name of the csv???suppose USERID is the 1st column the USERID should be named in A in CSV while its data is under of it??is it possible?

Exporting Data From Mysql Using Php In Excel Form..?
I have a table in mysql wich contain a sim_number field which is 19 digit unsigned number. i have designed a script using php headear command for exporting data as excel. It is working but with the follwoing problem.
Since sim_number is 19 digit number when it get exported as .xls file. now when that .xls file is opened, excel automatically detect this sim_number as number and , since excel can store only 15 digit in number format it converts its last 4 digits to zeros.

Is there any way to get this sim_number exported as text so that excel store complete 19 digit number in text format. I cannot attach some charctor to this sim_number because of restricion on file format.

Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?

Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for.  Can anyone help me get the Agreed? table's background color to the colors above? Code:

Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias'
the mysql_fetch_field function returns a value $result=>table which
will contain the alias, not the actual table name.
Is there a way to get the actual table name ?

I am running mysql 4.1 and php 4.4

Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'.

There is one of each item in products and each product has it's own unique 'prodno'

There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example:

id = 1
prodid = 7001
qty = 300
price = 12.5

id = 2
prodid = 7001
qty = 400
price = 15.5

I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table.

Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item..

This is all very confusing to me, and I'm the one writing it. Let's try one last time..

Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.

CSV Exporting
I created the csv file, but it only shows the last record in my db. How can I make it show all of the records? Here's the code:

Exporting A Database
developed a php project using mysql as the database.i work on a win-nt machine....how do i export my database to the host server which runs linux???

Exporting To An XML File
I grabbed a web page and had it extract only the links between certain line numbers. Now I want to take that output and export it to an XML file in a format of my choosing. For example:

<a href="mysite.com">This is my site</a>

Would export to:

<link>mysite.com</link>
<description>
This is my site
</description>

I will then take that XML file and output it as HTML, however I already have this bit accomplished.

PHP Exporting To Quickbooks
I am working on a web-based payroll application (PHP/MySQL of course) that needs to be able to dump each employee's information in to a Quickbooks formatted file for payroll processing.

I have done this several times exporting to a tab/comma deliminated text file (usually MS Excel), but I was wondering if anyone could see any reason why it could not be done the same way (assuming that Quickbooks uses a a tab/comma file structure) for Quickbooks??? If it can be done would I use the same mechanics as I would for Excel (changing the file type meta tag)?

Database Exporting
Quite by accident, I found the mysqldump utility, that comes with MySQL,
which dumps/backsup a database, table, or record. It looks very versatile!

Does PHP have a way to export records of a MySQL database? Anything that
does the same independent of the database used?

Database Exporting
As part of the CMS that I've written, I would like to give users the ability
to backup their own databases. Is there any way that this can be done with
PHP? What I'd like is for them to click a link and for it to create a txt
file and open the "Save as" dialog box so that they can save it off to their
hard drive.

Exporting Csv File
I'm having issues getting all the information from 3-4 databases into one
csv file.. What easy thing am I missing this time?

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=export.csv");
header("Pragma: no-cache");
header("Expires: 0");
$select = "SELECT * FROM ordersCopy O, orders_products P, orders_total Q
WHERE O.orders_id=P.orders_id OR O.orders_id=Q.orders_id AND
orders_status=&#393;'";

$export = mysql_query($select);
$count = mysql_num_fields($export);
for ($i = 0; $i < $count; $i++) {
$header .= mysql_field_name($export, $i)." ";
}
while($row = mysql_fetch_row($export)) {
$line = ''
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = " ";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . " ";
}
$line .= $value;
}
$data .= trim($line)."
";
}
$data = str_replace("
", "", $data);
if ($data == "") {
$data = "
(0) Records Found!
";
}
print "$header
$data";

Exporting To Excel
I followed the really cool how to at http://www.phpfreaks.com/tutorials/114/0.php but I had to change some things to get it to stop giving me errors. After I did that It seemed to work great but it put everything into one cell in the excel document. Code:

Exporting To Microsoft Access
I have a PHP website with a mySQL database and a client wants to be able to see the database on his computer using Microsoft Access.

I would like to be able to make a special backdoor section for him, where he enters his username and password and is given a link which will make take a snapshot of the mySQL database and convert it to a Microsoft Access database which he can download to his computer.

Is this possible?

Since he isn't very computer savvy I need a way as user friendly as possible to let him download the database and view on his local computer.

Exporting Data To MS Excel
How to export data to xls file using PHP? Is it possible to edit a
look of document (like cell size, borders etc.) ?

Exporting From Db To Text File
I have the following sql statement that works from phpmyadmin and from the MySQL command line, but not php. The resultant $sql variable is the following:

$sql=select logrecno, county, sumlev
into outfile "/tmp/census.txt"
fields terminated by ','
lines terminated by ""
from sf1_msageo
where sf1_msageo.county=97 and sf1_msageo.sumlev=140

$result=mysql_query($sql); The query executes, returns no messages, and does not create a file. Any idea as to what I'm doing wrong?

File Exporting To Excel
This code exports data from my DB into an Excel file by using " " as the delimiter. It runs through the script over and over until it's done creating an Excel file with columns of data, but is there a way that I can add a value to the beginning of the script - thereby naming the columns? Code:

New Exporting / Getting News From Different Server
Which is the best way to fetch news from my server and display it on other sites. I have an admincp i would like to display announcements in from my site. Maybe just some how remotly including a file from my server or something.

Exporting Search Results To A CSV File
I am about to start programming up a database, where the client requies the data exported to a CSV file for use in mail merge documents etc.

What I would like to know is, if they run a query on the database, and only export five of the 10 fields in the table to the list, how would I go about reatining the field names on the first line of the CSV file?

Exporting Information From Entourage To A Website.
I have this new website for a client, it has a calender which shows events from a mysql database but they don't want to have to update the information to it manually.
What they are using is a program called Microsoft Entourage. What are the possible ways for me to be able to get that information every 1 hour and get it into a database?

BBCode Parsers And Exporting Text From A DB
I'm currently working on a simple (at least I had hoped) script to pull posts from a single "news" forum from phpbb and importing it on the front page of my site. It works great except for the BBCode issues.

It doesn't keep line breaks (biggest concern) as well as text colors, urls, etc (which was expected).  Talking with a friend, he tells me that I'm going to have to insert some BBCode parser to make things work right.  I have 3 questions regarding this:

1) is that my only answer?

2) should I try to use the phpbb BBCode parser that the forum uses?

3) should I install a custom BBCode parser instead?

I did not want to use a portal because they were just over bloated for what I needed and that was simply the posts from the forum itself w/o all the extras like who's online, last post made on the forums, etc.

Would it just be easier to try to strip down something like EZportal to just the info I need instead of trying to use this custom script?

Problems While Exporting Data Using Pipe Symbols
I am facing problems while trying to export data into
pipe format. In fact I am fetching records from mysql database and then
trying to create a text file ( using pipe as delimeter) , intending to
open in Excel.

The data is been inserted from textarea fields, where the
user can write text and may press enter key to format his text
accordingly. Now when the data entered into the database it keeps some
unidentified value so as to keep the formatting. Hence while displaying
the text file I find that lines are seperated according to the format
user gave. Thus creating the problem while opening up in the excel
file.

example:

Exporting Database To Excel (via Website, NOT PhpMyAdmin)?
I know via phpMyAdmin I can export my database in Microsoft Excel 2000 format, and can check a box to 'Create field names as first row', but it doesn't give me the php code used to achieve this. I need to have a page on a website so the administrators will be able to do this for themselves, does anyone know if this is possible?

From CSV To MySQL Table
I've a CSV file with 3 columns

ID - Price1 - Price2

How I would like to update the records of a MySQL tables that has the
same ID of the CSV files.

How Can I do this? Read from CSV and update MySQL table?

Select From A Mysql Table
I want to pull one field from a mysql table. How do I do that? Do I use SELECT? The field name is $sip_visitornum. And I want the last value that was inputted in to the db. I already have the code to get the visitor number but I don't know how to display data from the database properly. Thanks.

How To Create A MySQL Table With PHP?
How to create a MySQL table with PHP?

Getting Mysql Table Info?
Suppose I have a table with name 'tablename' in my database.

If I have no idea what are the contents of this table, is it still possible to retrieve the structural info in this table, like the field names and sizes?

Get Max Value In MySQL Table Field
I have a 2-field table "pageref".

The fields are: "pagerefno" - which is index and primary key, and "url".

I need to find the max value in "pagerefno", so wrote the following code:

$query ="SELECT max(pagerefno) FROM pageref";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
$row = mysql_fetch_row($result);
echo row[0];

But this results in a blank screen. I'd be grateful for a steer, here.

Search A MySQL Table
I want to create a php script to search a mySQL table. I started to create the script myself, but I got stuck, because the script became VERY complex. The reason why it's complex is this:

*the script must be able to search all four columns of the table.
if the user defines four different values to search (one for each type of variable (ie.: for each column)). If he doesn't give four values but by example only two, the script needs to search on these two values...

*the script needs to return all four values of all the rows that match the query

*the script may not return each result more than one time

*if possible, the script needs to return 'the best match' on top

examples:
consider a table with four columns:
animal_type |age | name | sex
horse | 5 |beauty| female
horse | 4 |bless |male
cat | 9 |***** |female

the query (horse,5,beauty,female) must return
horse | 5 |beauty| female (only one time!!! this sounds logic, but it isn't!!!)

the query(female) must return
horse | 5 |beauty| female
cat | 9 |***** |female

the query (horse, female) must return
1) horse | 5 |beauty| female
2) horse | 4 |bless |male
3) cat | 9 |***** |female
(number 1 must be on top; 2 and 3 may be changed of place, because they only match one variable!!)

Creating Mysql Table
I have PHP script that creates a mysql table. My problem is when I goto the following php page to access the table it says "missing table 'table name'" I look in phpmyadmin and its clearly there. Eventually after refreshing the page like ten times it detects and works. Do I have to reconnect the mysql connection or something?

PHP MySQL Updating Table Row
I have a small database of books that a client can add, search and edit (hopefully) books; all online (something very simple). So far I've been successful in creating the adding of books and searching and retrieving the info in fields to edit; but I haven't been able to execute the edits. Here's the script I have to retrieve the database info and place them in the fields to edit (I didn't copy all the mysql connection script, it works fine): PHP Code:

How To Get A Field In The Last Row Of Mysql Table.
There is a certain field that I wish to get in the last row (it will always be in the last row, even if I add to the table) of my mysql table. How do I output this? I assumed that I would be using a LIMIT command and a DESCRIBE command, however I looked at mysql.com and couldn't find anything .

Table Dump With MySQL
I have recently moved from a host that provided only 1 mySQL db, to a host that allows multiple db's. How do I dump a table, or tables from the single db...into a new db(s)?
I've used this before (to dump the entire db):

mysqldump -h mysite.com -q mysite_dbname > db_dump.sql -pmysitepassword

but I want to extract specific table(s) from the origian db and move them into newly created db's of their own on the new server.

Mysql Empty Table
does anyone know what the mysql comand to empty and table?

MySQL Table Create
Here is the code I'm trying to create the database with (I'm using phpMyAdmin so I just select the file I want to use and press submit and it creates the tables).

CREATE TABLE bips (
banned_ip varchar(15) NOT NULL);

CREATE TABLE messages (
entry_id double(16,4) DEFAULT &#390;.0000' NOT NULL auto_increment,
name varchar(25) NOT NULL,
email varchar(35) NOT NULL,
icq int(11) NOT NULL,
http varchar(50) NOT NULL,
message mediumtext NOT NULL,
when int(12) NOT NULL,
ip varchar(15) NOT NULL,
UNIQUE entry_id (entry_id),
PRIMARY KEY (entry_id));

------------------------
phpMyAdmin gives me an error with that, (none of those tables exists btw)... the error is

MySQL said: You have an error in your SQL syntax near 'when int(12) NOT NULL, ip varchar(15) NOT NULL, UNIQUE entry_id (entry_i' at line 8 .

Getting Mysql Table Size?
How would I go about getting the size of a table in a mysql database with php? I am unable to find info on this in the manual. Which page is it on?

PHP Variables From Mysql Table
I have a PHP script which parces a mySQL table and shows which
sections meet on which day by using an array containing (mon,...Fri)
and another lisitng sections. I then have the PHP do to selecrt
statements on to list those sections that are mixed and those that are
not.

I have a title "Open to Boys and Girls" then it cycles through the
applicable groups. I want to hide this title if there are no group
from the mysql search but can't figure out how as the actual varaible
$result is set once the search is done even if it pulls nothing back

Code is below,

CODE
-------------------------------------------
$result = @mysql_query("SELECT Group_Name FROM `groups` where
".$section."_comment like '%".$day."%' and ".$section."_comment like
'%mixed%'");
echo "<u>Open to Boys & Girls</u></br>";
while($row = mysql_fetch_array( $result )) {
$Group_Name = $row['Group_Name'];
echo "&bull; ".$Group_Name."</br>";
}// end Group Name loop mixed

Creating Table Using PSP And MySQL
Ok, so Ive overcome the first hurdle of connecting to MySQL and MyDatabase on my
web server using PHP scripts. Now I want to create a simple table with 3
fields. Don't have a clue where to start using PHP.

Date Into Mysql Table?
how I can add a date to a mysql table with php? I am wanting to add the date when an article has been entered into the table.

Table Locking In MySQL
As there is no concept of Record locking in MySQL, Table has to be locked. If a Table is locked by one user, what happens to the other user who is accessing the table at that precise moment. Both are trying for a write access. What if the table is locked for more than a stipulated time. How should the script be written so that the other table who does not get write access waits.

Random Row From MySQL Table
I'm using PHP3, does anyone know how I can pull a random row from a mySQL table?

Make A Table In MySQL
How do I make a PHP script that is able to make tables with fields? I want to be able to have a HTML form submit the fields. I just want to know the PHP scriptlet that will make a table.

Create Mysql Table
I'm trying to create a mysql table in php. i have no problems doing a select, insert or anything else. i just don't know what the proper code is to create a table if it even exists.

Deleting From Mysql Table
i'm trying to replace a record in a mysql table but i'm having problems. First i've got a page to store existing film name values using:

<input type="hidden" name="Name" value= "<?printf($row["Name"])?>">

The second page is supposed to delete the existing record by comparing the stored name value with the database name but it only creates a a duplicate record. Here is the code for this: Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved