Note that there are some explanatory texts on larger screens.

plurals
  1. POphp count error
    primarykey
    data
    text
    <p>As you see I have created drop down and give it name the field name, and I have also the count function.</p> <p>What I want to do is, if some select drop down menu..show the how many result found in number like 10, 20,.. if the second dropdown selected it will check the two drop down selected and pass the result count..like that continuous..if you want to see example what exactly I want is go here and choose car the count will update..</p> <p><a href="http://en.comparis.ch/Carfinder/marktplatz/Search.aspx" rel="nofollow noreferrer">http://en.comparis.ch/Carfinder/marktplatz/Search.aspx</a></p> <p>I have the ajax and working well but I can't get the exact PHP code to count in live time.</p> <p>AJAX Code..</p> <pre><code>var xmlHttp function showCount(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="phpApplication.php"; url=url+"?action=count2"; url=url+"&amp;sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("POST",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("countR").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </code></pre> <p>PHP Code</p> <pre><code>function dropdown($field, $table) { //initialize variables $oHTML = ''; $result = ''; //check to see if the field is passed correctly if (($field == "")||($table == "")) { die("No column or table specified to create drop down from!"); } $sql = "select distinct($field) from $table"; //call the db function and run the query $result = $this-&gt;conn($sql); //if no results are found to create a drop down return a textbox if ((!$result) ||(mysql_num_rows($result)==0)) { $oHTML .= "&lt;input type='text' name='$field' value='' size='15'&gt;"; }elseif (($result)&amp;&amp;(mysql_num_rows($result)&gt;0)){ //build the select box out of the results $oHTML .= "&lt;select name='$field' onchange='showCount(this.value)'&gt;\n&lt;option value='all'&gt;All&lt;/option&gt;\n"; while ($rows = mysql_fetch_array($result)) { $oHTML .= "&lt;option value='".$rows[$field]."' name='".$rows[$field]."'&gt;".$rows[$field]."&lt;/option&gt;\n"; } $oHTML .= "&lt;/select&gt;\n"; } //send the value back to the calling code return $oHTML; }//end function function count1(){ $sql2 = "SELECT SQL_CALC_FOUND_ROWS * from produkt_finder_table where Bauform_d ='".($_POST['Bauform_d'])."' "; $query = $this-&gt;conn($sql2); $result = mysql_query( $query ); $count = mysql_result( mysql_query( 'SELECT FOUND_ROWS()' ), 0, 0 ); echo $count; //$sql2 = "SELECT COUNT(Bauform_d) from produkt_finder_table where Bauform_d = 'mobil' "; //echo var_dump($result1); while($row = mysql_fetch_array($query)) { // echo $row['COUNT(Bauform_d)']; } //echo mysql_num_rows($query); // if (isset($_POST['Bauform_d'])) //{ /* if (mysql_num_rows($result)==0) { echo '0'; } else { echo mysql_num_rows($result); $row = mysql_fetch_array($result); echo $result; echo $row['COUNT(Bauform_d)']; // } }*/ } $action = $_GET['action']; $proFin = new Application(); switch($action) { case 'show': $proFin-&gt;show_form(); break; case 'search': $proFin-&gt;search(); break; case 'searchAll': $proFin-&gt;searchAll(); break; case 'count2': $proFin-&gt;count1(); break; } </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.
    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