RSS Forums RSS
Please support our MySQL advertiser: Programming Forums

My Sql Reports

Join Date: Apr 2005
Location: Dundee, Scotland
Posts: 13,041
Reputation: jbennet is just really nice jbennet is just really nice jbennet is just really nice jbennet is just really nice 
Rep Power: 33
Solved Threads: 310
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is online now Online
Moderator

Re: My Sql Reports

  #2  
Mar 28th, 2007
you can do it in php . Here is the code i use to show a report of all the people whose email adresses and names i have in my database
 
<html>
<head>
<title>Test MYSQL PHP Page</title>
</head>
<body>
<?php
include("dbinfo.inc.php");
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><u><center>Database Output</center></u></b><br>";
echo "<hr>";
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$email=mysql_result($result,$i,"email");
echo "<b>$first $last</b><br>$email<br><hr><br>";
$i++;
}
?>
<p>
<center><a href="/index.php">Return to main page</a></center>
</p>
</body>
</html>
 

dbinfo.inc should contain something like:

 
<?php
$user="root";
$password="letmein";
$database="mydatabase";
?> 
 
Last edited by jbennet : Mar 28th, 2007 at 7:26 am.
TRY MY SUGGESTIONS AT YOUR OWN RISK

Master of puppets Im pulling your strings, blinded by me, you cant see a thing. Master! Master!
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:11 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC