// ユーザーID別
<?php
$user_id = 1;
$getall = mysql_query("SELECT name,username,email FROM users WHERE user_id = $user_id");
$row = mysql_fetch_assoc($getall);
$fullnameDB = $row['name'];
$emailDB = $row['email'];
$usernameDB = $row['username'];
?>
// メールとパスワードで
<?php
$email = $_POST["email"];
$password = $_POST["password"];
$getall = mysql_query("SELECT name,username,email FROM users WHERE email = '$email' AND password = '$password'");
$row = mysql_fetch_assoc($getall);
$fullnameDB = $row['name'];
$emailDB = $row['email'];
$usernameDB = $row['username'];
?>
私は(codeigniterモデルにクエリがあります)経由でそれを行います:
$this->load->model("ModelName");
$query = $this->ModelName->functionNameInModel(params);
$result = $query->result();
if ($query->num_rows() > 0)
{
$row = $query->row();
$var = $row->table_column;
echo("var = " . $var);
} else {
// No records returned! HOLY ****! HUSTON WE GOT A PROBLEM!
// Handle it with some code here...
}