Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>Grab all users & email addresses from MySQL </title></head>
- <body bgcolor="#FFFFFF">
- <?
- /* declare some relevant variables */
- $DBhost = "localhost";
- $DBuser = "YOUR DATABASE USERNAME";
- $DBpass = "YOUR DATABASE PASSWORD";
- $DBName = "YOUR DATABASE";
- $table = "YOUR TABLE NAME"; // not sure if this is needed since we run a sqlquery below
- mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
- @mysql_select_db("$DBName") or die("Unable to select database $DBName");
- $sqlquery = "SELECT * FROM `YOUR TABLE NAME` WHERE 1"; // change YOUR TABLE NAME to the actual name of the table you want
- $result = mysql_query($sqlquery);
- $number = mysql_numrows($result);
- $i = 0;
- if ($number < 1) {
- print "<CENTER><P>There Were No Results for Your Query</CENTER>";
- }
- else {
- while ($number > $i) {
- $thename = mysql_result($result,$i,"user");
- $theemail = mysql_result($result,$i,"email");
- print "<p><font color=#990000><b>Name:</b></font> $thename<br><font color=#990000><b>E-Mail:</b></font>
- $theemail</p>";
- $i++;
- }
- }
- ?>
- </BODY></HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement