webERP Forum
Loading in a div via ajax - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1)
+--- Forum: How To ? (http://www.weberp.org/forum/forumdisplay.php?fid=6)
+--- Thread: Loading in a div via ajax (/showthread.php?tid=8056)



Loading in a div via ajax - HDeriauFF - 01-18-2018

I created a new page that uses an Ajax updater framework with a callback to load content in a div.

my question: what would be the simplest way to hardcode a query WITHOUT calling include/sessions.php at the beginning of my callback file?

my target file only contains this:

$sql = "SELECT description
FROM stockmaster
WHERE stockid = '".$_POST["pID"]."' ";
$result = DB_query($sql);


Thanks


RE: Loading in a div via ajax - TimSchofield - 01-18-2018

You need to import config.php (or hard code the database variables from that script into your own) and then to connect to the database using the PHP function mysqli_connect() and use the handle returned from that in a call to the mysqli_query() function and use the return of that to call the mysqli_fetch_array() function.

To see how it all works look at the includes/ConnectDB_mysqli.php script.

Thanks
Tim


RE: Loading in a div via ajax - HDeriauFF - 01-19-2018

Thank you!
All done, works like a charm! (improving the quick entry screen by loading product names next to the code to detect mistakes earlier during input)