jquery - How to I use ajax and PHP to create and populate div elements? -


I had asked a similar question before, and it took me to the right path, but I am still a little stumped though, Now I know how to ask a more educated question.

I have a database that I connect to a table of products. Within the products there are column IDs, stocks, SHORTNAME, descriptions, PRICE and shipping.

If the user clicks on a button, then I need to send a request to find all the rows in the products. I believe that the following file.php completes (DB Connect Code Does not show up).

  $ query = "SELECT` ID` to` PRODUCTS '"; $ Result = mysql_query ($ query) or die ('query failed:'. Mysql_error ()); $ Num = mysql_numrows ($ Result);  

When a user clicks on the button, and it becomes $ num, then there are many div elements that make up the line because I have it for () But I'm 100% sure how to do this. Besides, I'm not sure how to do this with J.K.R in JQR, rather than just JS.

  function ajax function (phpFunction) {var ajaxRequest; Try {ajaxRequest = new XMLHttpRequest (); } Hold (e) {try {ajaxRequest = new ActiveXObject ("Msxml2.XMLHTTP"); } Hold (e) {try {ajaxRequest = new ActiveX object ("Microsoft.XMLHTTP"); } Hold (e) {Warning ("Your browser broke!"); return false; }}} // Create a function that will receive the data sent from the server ajaxRequest.onreadystatechange = function {if (ajaxRequest.readyState == 4) {for (var i = 0; i & lt; ajaxRequest.responseText; i ++) // Create the Div code here}} var url = "file.php; ajaxRequest.open (" GET ", URL, true); ajaxRequest.send (null);}  

So here are the last questions:

  1. If a user clicks on a specific device ( #revealProductButton ), then how many divs do I have for $ num < / Code> returns?
  2. How do I create a display made by DB STOCK, PRICE, and SHIPPING Every developer should display his own information, and not just a single div is displayed.
  3. If the user then clicks on one of the divisions, then I will use DB (DESCRIPTION , Etc.), but only clicked for that device?
  4. How do I write my file.php To work with all of this

    You can do something like this:

    (var i = 0; I & lt; AjaxRequest.responseText; I ++) {var div = document.createElement ("div"); Var Doctor = Document. GetElementsByTagName ("body") [0]; Doc.appendChild (div); Div.setAttribute ("id", "div_" + i); // Now to get shares, PRICE, and shipping through SQL queries, some PHP code / ........................... / / ......................... // ...................... . .... // Javascript again document.getElementById ("div_" + i) WinnerHTML = & lt ;? Php $ value, $ shipping, etc. Any way you want? & Gt ;; Div.onclick = function () {// to get more information again php code DESCRIPTION // .................. document.getElementById ("div_" + i ) Internal HTML + = '& lt; Br / & gt; & Lt; Br / & gt; + & Lt ;? Php $ details? & Gt; }; }

    Hope that helps.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -