-1

Ok thanks to all of u guys for your answers.

I've made some changing but i still can't display my array ...

Look at what i've done :

$prog = array();
$i=0;


        while($row = $get_programmation->fetch_assoc()){
        $prog[$i] = $row;
                $i++;
        }

echo json_encode($prog);

I would have this a result like this : {"id":"0","artist":"xxxx", .... etc} and then use it in my iOS app to display what i want.

Yoann
  • 3
  • 2

3 Answers3

0
mysql_query("SELECT * FROM `programmation`");

Backticks instead of single quotes

Also in here $articles[] = $row;

in $row variable you have to specify MySQL table column names which you have to insert into array, for instance $row['id'], etc...

NOTE: See mysql_ deprecated post too

Community
  • 1
  • 1
nanobash
  • 5,419
  • 7
  • 38
  • 56
0

you can not use quotes in table name or field name but you can use backtick()

$get_programmation = mysql_query("SELECT * FROM 'programmation'");

should be:

$get_programmation = mysql_query("SELECT * FROM `programmation`");

or

$get_programmation = mysql_query("SELECT * FROM programmation");
Awlad Liton
  • 9,366
  • 2
  • 27
  • 53
0

Replace this $get_programmation = mysql_query("SELECT * FROM 'programmation'");

with this $get_programmation = mysql_query("SELECT * FROM programmation");

Then importantly change code in while loop as below

    while($row = mysql_fetch_assoc($get_programmation)){
        array_push($articles, $row['yourcol1'],$row['yourcol2']);
    }
echo json_encode($articles);

$row is not actual array. You can get the value if it using your actual column name only. And here I have pushed it to the array in while loop to form as array.(Here I have mentioned only two column, You can take all your columns in such way.)

SIBHI S
  • 667
  • 1
  • 12
  • 19