expected ALL but reads only first

Codes here !

Moderators: macek, egami, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: expected ALL but reads only first

Post by egami » Thu Nov 08, 2012 8:13 am

I've never been much for object programming..


but try this..

Code: Select all

<?php 
<?php 

$connect = mysql_connect('host','user','pass');
$db = mysql_select_db('MyDatabase');

$table = "change_me";

$query = "SELECT * FROM $table";
$result = mysql_query($query);

if (mysql_num_rows($result) > 0) 
{
  while ($row = mysql_fetch_assoc($result))
  {
    echo '<pre>'; print_r($row); echo '</pre>';
  }
} else { 
  echo mysql_error();
}
  

MeroD
New php-forum User
New php-forum User
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am

Re: expected ALL but reads only first

Post by MeroD » Fri Nov 09, 2012 9:54 pm

if($result = $mysqli->query($query)){
while($row = $mysqli->fetch_object($result)){
echo $row->column;
}
}

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests