Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default New to accessing mysql dbase in excel vba

Hi everyone !

I've never done it before, but I need to get some data out of a mysql
database.
I'm still using Excel97 SR-2.

The following php script does exactly what I want to do : My question is :
how can I do it with a VBA Sub ???
<?php
// Here we tell the browser that this is an excel file.
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=testing.xls");
header("Pragma: no-cache");
header("Expires: 0");

$user = "username"; //MySQL Username
$password = "userpassword"; // MySQL Username's Password
$dbname= "databasename"; //Database Name
$tablename ="tablename"; // DB Table Name

// localhost is the default database hosf for most servers, you might need
to change yours if it doesnt work
$global_dbh = mysql_connect("mysqlserver", $user, $password); // This
establishes the database connection

mysql_select_db($dbname, $global_dbh); // Select what database to use

// You do not need to change the function
function display_db_table($tablename, $connection)
{
$query_string = "select * from $tablename";
$result_id = mysql_query($query_string, $connection);
$column_count = mysql_num_fields($result_id);

while ($row = mysql_fetch_row($result_id))
{
for ($column_num = 0;$column_num < $column_count; $column_num++)
{
echo "$row[$column_num]\t";
}
echo "\n";
}
}

display_db_table($tablename, $global_dbh);
// You can have multiple tables in one excel spreadsheet, just copy the
line to the left and change the table name.
?


Thanks a lot for your help and regards from Belgium,
Hervé+
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Should/Can Excel be used as a dbase Cmennis Excel Discussion (Misc queries) 4 June 9th 08 12:51 PM
Best way to export from Excel to MySQL? evillen Excel Discussion (Misc queries) 1 March 3rd 06 11:02 PM
Import MySQL data to Excel mbeyer Excel Discussion (Misc queries) 0 November 30th 05 07:10 PM
MySQL and excel bawar Excel Discussion (Misc queries) 1 January 9th 05 07:57 PM
Excel and Dbase Jeremy Lowe Excel Programming 2 January 8th 04 10:17 AM


All times are GMT +1. The time now is 03:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"