-4
select onchange 이벤트에서 ALL을 선택하면 while 루프가 실행되지 않습니다.ALL을 선택할 때 ALL 레코드를 표시하는 방법
dropdown.php
<script>
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
<?php
$mysqli = new mysqli("localhost", "root", "", "app");
$result = $mysqli->query("SELECT rfq FROM procurement GROUP BY rfq ORDER BY rfq");
$option = '';
while($row = $result->fetch_assoc())
{
$option .= '<option value = "'.$row['rfq'].'">'.$row['rfq'].'</option>';
}
?>
<select name="users" onchange="showUser(this.value)">
<option value="ALL" selected='ALL'>ALL</option>
<?php echo $option; ?>
</select>
<br>
<div id="txtHint"></div>
내가 showuser에 몸을 설정
<?php
$mysqli = new mysqli("localhost", "root", "", "app");
$q=$_GET["q"];
$result1 = $mysqli->query("SELECT *,SUM(unit_cost*quantity) AS total_amount FROM procurement WHERE rfq='".$q."' GROUP BY counter ORDER BY rfq");
echo'<table id="tfhover" cellspacing="0" class="tablesorter">
<thead>
<tr>
<th id="none" class="none" title="RFQ"></th>
<th title="RFQ">RFQ #</th>
<th title="Item Name">Item Name</th>
<th title="Item Description">Description</th>
<th title="Example : Pc, Pcs, Box and Etc.">Unit</th>
<th title="Item Price">Unit Cost</th>
<th title="Total Item Quantity">QTY</th>
<th title="Total Price">Total Amount</th>
</tr>
</thead>';
echo'<tbody>';
while($row = $result1->fetch_assoc()){
echo'<tr>
<td align="center"><a href="comments.php?pn='.$row["rfq"].'"><img src="images/remarks.png" border="0" width="10" height="10" title="Remarks and Notes"></a></td>
<td>'.$row['rfq'].'</td>
<td>'.$row['item_name'].'</td>
<td>'.$row['item_description'].'</td>
<td>'.$row['unit'].'</td>
<td>'.number_format($row['unit_cost'], 2, '.', ',').'</td>
<td>'.$row['quantity'].'</td>
<td>'.number_format($row['total_amount'], 2, '.', ',').'</td>
</tr>';
}
echo "</tbody></table>";
echo $q;
if (!$mysqli) {
die('Connect Error: ' . mysqli_connect_error());
}
mysqli_close($mysqli);
?>
getuser.php (STR = "ALL")하지만, 그냥 모든 동안 루프 ISN을 선택하면 사진처럼 실행 중입니다. 문제가 무엇입니까?
대단 했어요! 고마워. :) 한가지 더. 내 테이블에 대한 스크립트, 정렬 및 행의 색상 마우스를 때. 그러나 그것은 작동하지 않습니다. 나는 위의 스크립트가 getuser.php의 다른 스크립트에 영향을 끼친다고 생각합니다. –
자바 관련 질문을 게시하고 두뇌를 생각하게하십시오. Btw, 내 솔루션이 문제를 해결하면 받아 들일 수있는대로 내 대답을 표시 할 수 있습니다 :) – Kita
마크 없음 @Kita hahahahaha – user2705620