Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // Connects to the MySQL database
- $dbhost = 'achivements.org.mysql'; // MySQL Host
- $dbuser = 'achivements_org'; // MySQL Username
- $dbpass = '?????????'; // MySQL Password
- $dbname = 'achivements_org'; // MySQL Database
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('An error occurred while trying to connect to the MySQL database: ' . mysql_error());
- mysql_select_db($dbname);
- class MySQL
- {
- // Prints a row from the MySQL database
- public function get_rows($row_name, $table, $id = false)
- {
- if($id == true)
- {
- $SQL = "SELECT * FROM $table";
- $result = mysql_query($SQL);
- if (!$result)
- {
- echo "Could not successfully run query ($sql) from database: " . mysql_error();
- exit;
- }
- if (mysql_num_rows($result) == 0)
- {
- echo "No rows found";
- }
- while ($row = mysql_fetch_assoc($result))
- {
- $data[] = array(id => $row['id'], name => $row[$row_name]);
- }
- return $data;
- mysql_free_result($result);
- }
- else
- {
- $SQL = "SELECT * FROM $table";
- $result = mysql_query($SQL);
- if (!$result)
- {
- echo "Could not successfully run query ($sql) from database: " . mysql_error();
- exit;
- }
- if (mysql_num_rows($result) == 0)
- {
- echo "No rows found";
- }
- while ($row = mysql_fetch_assoc($result))
- {
- $arr[] = $row[$row_name];
- }
- return $data;
- mysql_free_result($result);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement