Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1.  
  2. <html>
  3. <head><title>Grab all users & email addresses from MySQL </title></head>
  4. <body bgcolor="#FFFFFF">
  5.  
  6. <?
  7. /* declare some relevant variables */
  8. $DBhost = "localhost";
  9. $DBuser = "YOUR DATABASE USERNAME";
  10. $DBpass = "YOUR DATABASE PASSWORD";
  11. $DBName = "YOUR DATABASE";
  12. $table = "YOUR TABLE NAME"; // not sure if this is needed since we run a sqlquery below
  13.  
  14. mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
  15. @mysql_select_db("$DBName") or die("Unable to select database $DBName");
  16. $sqlquery = "SELECT * FROM `YOUR TABLE NAME` WHERE 1"; // change YOUR TABLE NAME to the actual name of the table you want
  17. $result = mysql_query($sqlquery);
  18. $number = mysql_numrows($result);
  19.  
  20. $i = 0;
  21.  
  22. if ($number < 1) {
  23. print "<CENTER><P>There Were No Results for Your Query</CENTER>";
  24. }
  25. else {
  26. while ($number > $i) {
  27. $thename = mysql_result($result,$i,"user");
  28. $theemail = mysql_result($result,$i,"email");
  29. print "<p><font color=#990000><b>Name:</b></font> $thename<br><font color=#990000><b>E-Mail:</b></font>
  30. $theemail</p>";
  31. $i++;
  32. }
  33. }
  34. ?>
  35. </BODY></HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement