Results 1 to 8 of 8
Thread: PHP - mysqli_query
Hybrid View
-
28th November 2012 11:08 #1
PHP - mysqli_query
,
:
email_list - first_name,last_name,email.
John,Simpson,john@yahoo.com
show_data.php
PHP Code:$dbc = mysqli_connect('localhost','root','','customersDB') or die('Error connecting to MySQL server.');
$query = "SELECT first_name,last_name FROM email_list WHERE email='peter@yahoo.com'";
$result = mysqli_query($dbc,$query) ;
if(!$result){
echo 'No people found!';
}else{
while($row = mysqli_fetch_array($result)){
echo $row['first_name']. ' '.$row['last_name'].'<br />';
}
}
$query , elsa , if .
var_dump($result)
? PHPCode:object(mysqli_result)[2] public 'current_field' => null public 'field_count' => null public 'lengths' => null public 'num_rows' => null public 'type' => null

-
28th November 2012 11:22 #2
- , ?
( ), $result (), if (!$result) .
( ).
num_rows() mysqli_result , .
Edit: , , num_rows , , ..
$result->num_rows > 0.Last edited by tedych; 28th November 2012 at 11:50.
-
28th November 2012 11:36 #3
-
28th November 2012 11:52 #4Registered User
Join Date: Jul:2005
Location: Sofiq
Posts: 2,798
mysqli_result
$result->num_rows .mysqli_result implements Traversable {
/* Properties */
int $current_field ;
int $field_count;
array $lengths;
int $num_rows;
.....
}
-
28th November 2012 11:55 #5
-
28th November 2012 11:58 #6
.PHP Code:
....
if(!mysqli_num_rows($result)){
echo 'No people found!';
}else{
while($row = mysqli_fetch_array($result)){
echo $row['first_name']. ' '.$row['last_name'].' '.$row['email'].'<br />';
}
}
....
, !
-
28th November 2012 12:02 #7




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in