예제 #1
0
 public function getSpecificSport($id)
 {
     $sid = $id;
     $table = "locations";
     $config = new config("localhost", "root", "", "play_a_sport_db", "", "mysqli");
     $db = new db($config);
     $db->openConnection();
     $sql = $db->query("SELECT id,location_name,latitude,longtitude FROM {locations} WHERE `id`=" . $sid);
     $result = $db->fetchArray($sql);
     $db->closeConnection();
     $_SESSION['id'] = $result["id"];
     $_SESSION['lname'] = $result["location_name"];
     $_SESSION['ltd'] = $result["latitude"];
     $_SESSION['lngtd'] = $result["longtitude"];
     $url = 'sport_edit.php';
     echo '<META HTTP-EQUIV=REFRESH CONTENT="0; ' . $url . '">';
 }
예제 #2
0
$entrdpwd = $getvals['password'];
//echo $getvals['username'];
//echo $getvals['password'];
// We need to have 1 config object with all data in.
$config = new config("localhost", "root", "", "play_a_sport_db", "", "mysqli");
//type in your data here…
// Now we need to have access to the db class, we uses the config object to configure the db object.
$db = new db($config);
// We can now open the connection to the database.
$db->openConnection();
// If your config details are right, we are now connected to a database, lets test the connection before we run queries.
$are_we_online = $db->pingServer();
// The variable $are_we_online should be true (or 1) if we are connected to the server.
//echo "Are we online: " . $are_we_online; // prints 0 or 1.
// Let us run a query.
$sql = $db->query("SELECT * FROM {admins}");
// The variable $sql will now hold the data returned from the database, we can now work with it.
// Does it have rows ?
/*$hasRows = $db->hasRows($sql);
  echo "Does it have rows: " . $hasRows; // prints 0 or 1 (true or false).
  
  // How many rows does it have.
  $countRows = $db->countRows($sql);
  echo "How many rows: " . $countRows; // returns the number of rows.*/
// We can get the data from the fetch_assoc function.
//$result = $db->fetchAssoc($sql);
// We can get the data from the fetch_array function.
$result = $db->fetchArray($sql);
//We can even print out the latest used query:
//echo $db->lastQuery();
$dbusername = $result['username'];