Advertisement
Guest User

Untitled

a guest
May 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.     //lets take in some info to connect with
  3.     $dbserver = 'localhost';
  4.     $dbusername = 'somewhereovertherainbow';
  5.     $dbpassword = 'mytummyboxfeelsbroken';
  6.     $dbname = 'somedb';
  7.  
  8.     //lets make the connection
  9.     mysql_connect($dbserver, $dbusername, $dbpassword);
  10.  
  11.     //now we need to select the database
  12.     mysql_select_db($dbname);
  13.  
  14.    
  15.     //Now lets get a resource that we can pass to mysql_fetch_array to convert to an array
  16.     $query = mysql_query("SELECT * FROM table WHERE feild = 'value'");
  17.  
  18.     //Now we can turn that into an array so we can use the data
  19.     $array = mysql_fetch_array($query);
  20.    
  21.     //Now lets echo one of the feilds in the database ascociated with the row.
  22.     echo $array['someFieldInTheDataBase'];
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement