Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

sql query array return not functioning properly

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

sql query array return not functioning properly

Postby qwerty123 » Fri Jan 24, 2014 7:55 am

first, let me state that i am new to programming.

The code below only returns the first row, and then repeats it until the script times out. i don't want it to do this, i want it to iterate over all the rows returning all the "names" in the database. what am i doing wrong?

everything i found on php.net seems to align with what i have when it comes to procedural style. I don't even speak object-oriented yet, so please don't point me to that.

the only thing i can figure is that there is a problem in my while() conditional, but i don't know what it would be.


Code: Select all
$connect = mysqli_connect('localhost', $u_name, $p_word, $db_name);
$query =  "SELECT * FROM `Dealers` LIMIT 0, 5 ";
$result = mysqli_query ($connect, $query);
$row = mysqli_fetch_assoc($result);

if ($result){
echo 'here are the results: '  ;
   while ($row){
   echo $row['names'];
   }
}
qwerty123
New php-forum User
New php-forum User
 
Posts: 2
Joined: Thu Jan 23, 2014 8:01 am

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron