Reputation: 97
function shopView(){
global $core;
$shop = mysql_query("SELECT * FROM services ORDER BY id DESC");
$return = '<article>';
if($shop){
while ($row = mysql_fetch_array($shop)) {
$return .= '<h4>'.$row['nazwa'].'</h4><a href="index.php?view=buy&service='.$row['id'].'" class="button">Kup za '.$row['koszt'].' zl (+vat)</a>';
}
}
else{
$return .= 'Niestety coś poszło nie tak ;/';
}
$return .= '</article>';
return $return;
}
I don't know why this $row['id']
doesn't work. I have some similar code and there is same code like ?value='.$query['auto_increment'].'
, and there everything is ok. Can somebody help me?
Upvotes: 2
Views: 213
Reputation: 380
use the following code
function shopView(){
global $core;
$shop = mysql_query("SELECT * FROM services ORDER BY id DESC");
$return = '<article>';
if($shop){
while ($row = mysql_fetch_array($shop,MYSQL_ASSOC)) {
$return .= '<h4>'.$row['nazwa'].'</h4><a href="index.php?view=buy&service='.$row['id'].'" class="button">Kup za '.$row['koszt'].' zl (+vat)</a>';
}
}
else{
$return .= 'Niestety coś poszło nie tak ;/';
}
$return .= '</article>';
return $return;
}
referencess http://php.net/manual/en/function.mysql-fetch-array.php
Upvotes: 2