A MYSQL....Reader?

  • OptionExp
  • Newbie
  • Newbie
  • User avatar
  • Posts: 5

Post 3+ Months Ago

Boss wants a simple interface to view/download data from my MySQL DBs. Simple enough for the lusers. Been googling for a while now and can't seem to find a good one.

If it can export to csv/xls that would be awesome. Anyone knows something as such? Basically a front-end of MySQL for non-techies.

I use phpmyadmin for my own use.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I was just going to recommend phpmyadmin, you might have to write yourself a simple script to do what you need. That way you can just have the features you want for your boss which should keep it as simple as it can, yet have everything it needs.

Here is an example file you could write to export to CSV:

PHP Code: [ Select ]
<?php
$host = 'localhost';
$user = 'mysqlUser';
$pass = 'myUserPass';
$db = 'myDatabase';
$table = 'products_info';
$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_H-i",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;
?>
  1. <?php
  2. $host = 'localhost';
  3. $user = 'mysqlUser';
  4. $pass = 'myUserPass';
  5. $db = 'myDatabase';
  6. $table = 'products_info';
  7. $file = 'export';
  8.  
  9. $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
  10. mysql_select_db($db) or die("Can not connect.");
  11.  
  12. $result = mysql_query("SHOW COLUMNS FROM ".$table."");
  13. $i = 0;
  14. if (mysql_num_rows($result) > 0) {
  15.    while ($row = mysql_fetch_assoc($result)) {
  16.       $csv_output .= $row['Field']."; ";
  17.       $i++;
  18.    }
  19. }
  20. $csv_output .= "\n";
  21.  
  22. $values = mysql_query("SELECT * FROM ".$table."");
  23. while ($rowr = mysql_fetch_row($values)) {
  24.    for ($j=0;$j<$i;$j++) {
  25.       $csv_output .= $rowr[$j]."; ";
  26.    }
  27.    $csv_output .= "\n";
  28. }
  29.  
  30. $filename = $file."_".date("Y-m-d_H-i",time());
  31. header("Content-type: application/vnd.ms-excel");
  32. header("Content-disposition: csv" . date("Y-m-d") . ".csv");
  33. header( "Content-disposition: filename=".$filename.".csv");
  34. print $csv_output;
  35. exit;
  36. ?>


I got this from this page:

http://www.tutorial5.com/content/view/159/85/

I am sure there are tons of example codes out there like this to allow you to do what you need.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 89 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.