Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loading in a div via ajax
01-18-2018, 09:01 AM, (This post was last modified: 01-18-2018, 09:03 AM by HDeriauFF.)
#1
Loading in a div via ajax
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
Reply
01-18-2018, 06:13 PM,
#2
RE: Loading in a div via ajax
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
Reply
01-19-2018, 03:11 AM,
#3
RE: Loading in a div via ajax
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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)