Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax responsetext as a table output?
    primarykey
    data
    text
    <p>I'm not really familiar with Ajax Response - I have edited the PHP Ajax Search code from W3schools.com as follows :</p> <pre><code>&lt;?php require_once('connect_db.php'); $query = "select item_no from items"; $result = mysql_query($query); $a = array(); while ($row = mysql_fetch_assoc($result)){ $a[] = $row['item_no']; } //get the q parameter from URL $q=$_GET["q"]; //lookup all hints from array if length of q&gt;0 if (strlen($q) &gt; 0) { $hint=""; for($i=0; $i&lt;count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint." , ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="No Suggestion"; } else { $response=$hint; } //output the response echo "&lt;table border=1&gt;&lt;tr&gt;&lt;td&gt;".$response."&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"; ?&gt; </code></pre> <p>The output of the above code works perfectly, but they are all listed like this (2L500BU , 2L500GO , 2L500NA , 2L500RD , 2L802CA , 2L802WH , 2L803GR , 2L804BE , 2L804BK , 2L804CO , 2L805BU , 2L806BE , 2L806GR ) <em>- Those numbers are Item No in mysql table called items.</em></p> <p>Now :</p> <p><strong>1)</strong> I want to output the response into table with <code>&lt;tr&gt;</code> for each like this</p> <p>2l500BU</p> <p>2L500GO</p> <p>.</p> <p>.</p> <p>.</p> <p>. etc.</p> <p><strong>2)</strong> Do you think its possible to output all table records from Mysql based on the hint entered as follows :</p> <pre><code>$sql="SELECT * FROM items WHERE item_no = '".**$hint**."'"; $result = mysql_query($sql); echo "&lt;table align='center' cellpadding='3' cellspacing='3' width='800px' border='1' font style='font-family:arial;'&gt;"; echo " &lt;tr align=center&gt; &lt;th style=font-size:18px; bgcolor=#20c500&gt;Item Number&lt;/th&gt; &lt;th style=font-size:18px; bgcolor=#20c500&gt;QTY&lt;/th&gt; &lt;th style=font-size:18px; bgcolor=#20c500&gt;Actual Price&lt;/th&gt; &lt;th style=font-size:18px; bgcolor=#20c500&gt;Selling Price&lt;/th&gt; &lt;th style=font-size:18px; bgcolor=#20c500&gt;Difference&lt;/th&gt; &lt;th style=font-size:18px; bgcolor=#20c500&gt;Date&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_assoc($result)){ echo "&lt;tr align=center bgcolor=#e3e3e3&gt;"; echo "&lt;td style='font-size:18px; font-weight:bold;'&gt;" . strtoupper($row['item_no']) . "&lt;/td&gt;"; echo "&lt;td style='font-size:18px; font-weight:bold;'&gt;" . $row['qty'] . "&lt;/td&gt;"; echo "&lt;td style='font-size:18px; font-weight:bold;'&gt;" . $row['actual_price'] . "&amp;nbsp;&lt;font style=font-size:12px;&gt;JD&lt;/font&gt;&lt;/td&gt;"; echo "&lt;td style='font-size:18px; font-weight:bold;'&gt;" . $row['discount_price'] . "&amp;nbsp;&lt;font style=font-size:12px;&gt;JD&lt;/font&gt;&lt;/td&gt;"; echo "&lt;td style='font-size:18px; font-weight:bold;'&gt;" . $row['difference_price'] . "&amp;nbsp;&lt;font style=font-size:12px;&gt;JD&lt;/font&gt;&lt;/td&gt;"; echo "&lt;td style='font-size:18px; font-weight:bold;'&gt;" . date("d-m-Y",strtotime($row['date'])) . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;table&gt;"; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload