class wont return list php -
hi started lear oop , came acros problem, whwn used script in normal scripring sequence ecoed out list of items when put class file first line problem? class file:
<?php class getpvm{ function ($sql){ while($row = mysql_fetch_array($sql)){ $id = $row["product_id"]; $product_name = $row["product_name"]; $price = $row["price"]; return $list =' <li>'.$id .' '.$product_name.' '.$price.'(pvm '.$price*0.21 .') </br></li>'; } } }
and call this:
$sql = mysql_query("select * product"); echo $list=($getpvm->get($sql))
use below code , try:
class getpvm{ function ($sql){ $list = ''; while($row = mysql_fetch_array($sql)){ $id = $row["product_id"]; $product_name = $row["product_name"]; $price = $row["price"]; $list .=' <li>'.$id .' '.$product_name.' '.$price.'(pvm '.$price*0.21 .') </br></li>'; } return $list; } }
Comments
Post a Comment