Jump to content

Help select mysql, something wrong


Recommended Posts

Hi, i am new user of prestashop, and i try learn some of php

 

I need SELECT a order and show it, but something its wrong, here my code:

 

.php

if (!defined('_PS_VERSION_'))
	exit;

class Estadisticas extends Module
{
	private $_join = '';
	private $_where = '';

	public function __construct()
	{
		$this->name = 'estadisticas';
		$this->tab = 'estadisticas';
		$this->version = 1.0;
		$this->author = 'benito';
		$this->need_instance = 0;

		parent::__construct();

		$this->displayName = $this->l('estadisticas');
		$this->description = $this->l('estadisticas');
	}

	public function install()
	{
		return (parent::install() && $this->registerHook('AdminStatsModules'));
	}
	
	public function hookAdminStatsModules( $params ){
    global $smarty;

    $sql="select * from ps_orders"; // creamos la sentencia sql
    $query=mysql_query($sql); // ejecutamos la consulta

    while($row=mysql_fetch_array($query)){
        $datos=array($row['id_order']);
    }
    mysql_close();
    
    $smarty->assign('datos' ,$datos);
    return $this->display(__FILE__, 'estadisticas.tpl');
}

}

And tpl

<div id="module_testing_block_left" class="block">
    <h4>Estadisticas</h4>
    <div class="block_content">
        <table border="0" cellspacing="5" cellpadding="5">
            {foreach key=key name=outer item=dato from=$datos}
            <tr class="">
                {foreach key=key item=item from=$dato}
                <td align="left">{$item['id_order']}</td>
                {/foreach}    
            </tr>
            {/foreach}    
        </table>
    </div>
</div>

i need show id_order and my code not work 100% only show the h4

 

Thanks!

Link to comment
Share on other sites

×
×
  • Create New...