Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retain in the same selection after refresh?
    primarykey
    data
    text
    <p>How to retain with the same selection in dropdown when refresh or after I submit or delete? </p> <p>I have this code below that select value from database. I want to back with the same value in select dropdown after I refresh or I submit the form or delete records.</p> <p>bid.php</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function showUser(str) { var $txtHint = $('#txtHint'); if (str == "") { $txtHint.html(''); return; } $txtHint.load('bid_list.php?q=' + str) } &lt;/script&gt; &lt;/head&gt; &lt;body onload=showUser(str="ALL")&gt; &lt;?php $mysqli = new mysqli("localhost", "root", "", "app"); $result = $mysqli-&gt;query("SELECT bid FROM procurement WHERE bid LIKE '13-___' OR bid LIKE '1_-___' OR bid LIKE '2_-___' GROUP BY bid ORDER BY bid"); $option = ''; while($row = $result-&gt;fetch_assoc()) { $option .= '&lt;option value = "'.$row['bid'].'"&gt;'.$row['bid'].'&lt;/option&gt;'; } ?&gt; &lt;select name="users" onchange="showUser(this.value)" style="overflow:scroll;width:100px;"&gt; &lt;option value="ALL" selected='ALL'&gt;ALL&lt;/option&gt; &lt;?php echo $option; ?&gt; &lt;/select&gt; &lt;div id="txtHint"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <h2>bid_list.php</h2> <p></p> <pre><code>&lt;?php $mysqli = new mysqli("localhost", "root", "", "app"); $q = $_GET["q"]; $where = ''; if ( $q != 'ALL' ) { $where = " WHERE bid='$q' "; } $result1 = $mysqli-&gt;query(" SELECT bid, item_name, item_description, unit, unit_cost, quantity, supplier, po_number, po_date, counter, SUM(unit_cost*quantity) AS total_amount FROM procurement $where GROUP BY counter ORDER BY bid "); echo'&lt;table id="tfhover" cellspacing="0" class="tablesorter" style="text-transform:uppercase;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th colspan="3" id="none" style="cursor: default;"&gt;&lt;/th&gt; &lt;th title="Item Name"&gt;Item Name&lt;/th&gt; &lt;th title="Item Description"&gt;Description&lt;/th&gt; &lt;th title="Example : Pc, Pcs, Box and Etc."&gt;Unit&lt;/th&gt; &lt;th title="Item Price"&gt;Unit Cost&lt;/th&gt; &lt;th title="Total Item Quantity"&gt;QTY&lt;/th&gt; &lt;th title="Total Price"&gt;Total Amount&lt;/th&gt; &lt;th title="Name of Supplier"&gt;Supplier&lt;/th&gt; &lt;th title="Purchase Order Date"&gt;PO Date&lt;/th&gt; &lt;th title="Purchase Order #"&gt;PO #&lt;/th&gt; &lt;th id="none" style="cursor: default;"&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt;'; echo'&lt;tbody&gt;'; while($row = $result1-&gt;fetch_assoc()){ if($row['bid'] != '') { echo'&lt;tr&gt; &lt;td align="center"&gt;&lt;a href="bid.php?de='.$row["counter"].'" onclick="return confirm(\'Really want to delete ?\');"&gt;&lt;img src="images/del.png" border="0" width="10" height="10" title="Delete"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;a class="fancybox" href="edit.php?pn='.$row["counter"].'"&gt;&lt;img src="images/edit.png" border="0" width="10" height="10" title="Edit"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;a class="fancybox" href="comments.php?pn='.$row["counter"].'"&gt;&lt;img src="images/remarks.png" border="0" width="10" height="10" title="Remarks and Notes"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;'.$row['item_name'].'&lt;/td&gt; &lt;td&gt;'.$row['item_description'].'&lt;/td&gt; &lt;td&gt;'.$row['unit'].'&lt;/td&gt; &lt;td&gt;'.number_format($row['unit_cost'], 2, '.', ',').'&lt;/td&gt; &lt;td&gt;'.$row['quantity'].'&lt;/td&gt; &lt;td&gt;'.number_format($row['total_amount'], 2, '.', ',').'&lt;/td&gt; &lt;td&gt;'.$row['supplier'].'&lt;/td&gt; &lt;td&gt;'.$row['po_date'].'&lt;/td&gt; &lt;td&gt;'.$row['po_number'].'&lt;/td&gt; &lt;td&gt;&lt;input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.$row['counter'].'"&gt;&lt;/td&gt; &lt;/tr&gt;'; } } echo "&lt;/tbody&gt;&lt;/table&gt;"; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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