Search the Community
Showing results for tags 'databasequery'.
-
Hi, I am doing a small module in prestashop. In that module I have some ajax request. In view file(.tpl file) I am getting the form. From that view file lets say I have one dropdown like this <label>Please Select store</label> <select id="storeinfo" class="storeinfo" onClick="getDetails();"> <option value="Select">Select</option> </select> and in .js file I am getting the value of city through like this function getDetails() { var storedetails = $('#storedetails').val(); $.ajax({ type: "GET", url: baseDir + "/modules/storedetails.php", cache: false, data: { details : storedetails }, success: function(html) { $(".box").html(html); } }); } and in storedetails.php I have done the query <?php include '../config/settings.inc.php'; include '../config/defines.inc.php'; include '../config/config.inc.php'; $connection = mysqli_connect(_DB_SERVER_,_DB_USER_,_DB_PASSWD_) or die(mysqli_error()); mysqli_select_db($connection,_DB_NAME_) or die(mysqli_error()); $result1 = "SELECT * FROM "._DB_PREFIX_."storeinfo WHERE `store_name`='".$_GET['storedetails']."'"; $result = mysqli_query($connection,$result1) or die(mysqli_error()); while($row = mysqli_fetch_array($result)){ echo '<div class="store-info-wrap">'; $phone_num = $row['store_name']; $address = $row['address']; echo "<strong>Phone Number</strong> ". $phone_num; echo "<strong>Store Address</strong> ". $address; echo '</div>'; } ?> This is working without any problem. But prestashop tells that you have to use dbclasses whenever you are doing any query like (Tools::getvalue). so here I want to know as I have one external .php file where I have to make my own connection to the database.Then how can I use prestashop db classes here? Any example or any help,suggestions will be really appreciable. Thanks..