Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php mysql_fetch_array

Tags:

sql

php

mysql

Hy,

I'm new in php and I'm having some problems with mysql_fetch_array().

$sql = "SELECT mandant_kurz FROM pu_mandant ORDER BY mandant_kurz ASC";

$result = mysql_query($sql);

$list = mysql_fetch_array($result);

There are more than 100 entries in the database but the mysql_fetch_array() delivers only one. When I'm trying it with a while-loop it isn't working either.

Here it goes with my while-loop

$sql = "SELECT mandant_kurz FROM pu_mandant ORDER BY mandant_kurz ASC";

$result = mysql_query($sql);

while($list = mysql_fetch_array($result));
like image 793
sebbl.sche Avatar asked Jun 28 '26 02:06

sebbl.sche


1 Answers

Update:

You are not doing anything inside your loop:

while($list = mysql_fetch_array($result));

Try:

while($list = mysql_fetch_array($result){
  echo $list['mandant_kurz'];
}

Also try running your query in MySQL client to make sure it actually returns 100 rows.


You will have to use loop:

while($row = mysql_fetch_array($result)){
   echo $row['mandant_kurz'];
}
like image 72
Sarfraz Avatar answered Jun 30 '26 17:06

Sarfraz