Jump to content

show a table of content from prestashop table


Golden Man

Recommended Posts

Hello ,

I created a module in Prestashop 1.6 and now i want to manage this module, i need to see table content because  saved data in 2 tables with ajax and now i want to see entred data i seen a configure button in the module but i can only show a form so i need to show a table liste.

This is my code :

public function getContent()
	{
	    $output = null;
	 
	    if (Tools::isSubmit('submit'.$this->name))
	    {
	        $my_module_name = strval(Tools::getValue('printpics'));
	        if (!$my_module_name
	          || empty($my_module_name)
	          || !Validate::isGenericName($my_module_name))
	            $output .= $this->displayError($this->l('Invalid Configuration value'));
	        else
	        {
	            Configuration::updateValue('printpics', $my_module_name);
	            $output .= $this->displayConfirmation($this->l('Settings updated'));
	        }
	    }
	    return $output.$this->displayForm();
	}
	public function displayForm()
	{
	    // Get default language
	    $default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
	    // Init Fields form array
	    $fields_form[0]['form'] = array(
	        'legend' => array(
	            'title' => $this->l('Settings'),
	        ),
	        'input' => array(
	            array(
	                'type' => 'text',
	                'label' => $this->l('Configuration champs'),
	                'name' => 'MYMODULE_NAME',
	                'size' => 20,
	                'required' => true
	            )
	        ),
	        'submit' => array(
	            'title' => $this->l('Save'),
	            'class' => 'button'
	        )
	    );
	     
	    $helper = new HelperForm();
	    // Load current value
	    $helper->fields_value['MYMODULE_NAME'] = Configuration::get('MYMODULE_NAME');
	     
	    return $helper->generateForm($fields_form);
	}

post-396791-0-75418400-1414151459_thumb.png

Link to comment
Share on other sites

Hi,

in one of my module, i have this:

 

<select name="table">';
if ($tables = Db::getInstance()->ExecuteS('SHOW TABLES FROM `'._DB_NAME_.'` LIKE "'._DB_PREFIX_.'%"'))
	foreach ($tables as $table)
		$this->_html .= '<option value="'.$table['Tables_in_'._DB_NAME_.' ('._DB_PREFIX_.'%)'].'"'.
			(($table['Tables_in_'._DB_NAME_.' ('._DB_PREFIX_.'%)'] == Tools::getValue('table'))? 'selected' : '' ).'>'.
			$table['Tables_in_'._DB_NAME_.' ('._DB_PREFIX_.'%)'].'</option>';
$this->_html .= '</select>
I do not know if it can help you ...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...