This question already has an answer here:
For example, I want to display Tan & Tan Developments
from my database. But, I dont know why it always show Tan only
My code shown below
<?php
require_once 'dbconfig.php';
$developer = $_POST['developer']; //I get the developer name
//this query is the get all the developer id
$DevQuery="SELECT id AS `ID` FROM pams_developer WHERE developer_name=:name";
$dev_id = ($GetReport->GetID($DevQuery,$developer));//implode out the id from array
$TotalSPAUnitQuery = "SELECT count(unit_id) AS 'COUNT' FROM pams_unit
JOIN pams_phase ON `pams_unit`.`phase_id`=`pams_phase`.`phase_id` AND `pams_unit`.`status_id`='3' AND `pams_unit`.`progress_id`='6'
JOIN pams_project ON `pams_project`.`project_id`=`pams_phase`.`project_id`
JOIN pams_developer ON `pams_developer`.`id`=:dev_id AND `pams_project`.`dev_id`=`pams_developer`.`id`";
$TotalSPAUnit = $GetReport->GetCount($TotalSPAUnitQuery,$dev_id);
$TotalSPAGDVQuery = "SELECT FORMAT(SUM(sold_price),2) AS 'COUNT' FROM pams_unit
JOIN pams_phase ON `pams_unit`.`phase_id`=`pams_phase`.`phase_id` AND `pams_unit`.`status_id`='3' AND `pams_unit`.`progress_id`='6'
JOIN pams_project ON `pams_project`.`project_id`=`pams_phase`.`project_id`
JOIN pams_developer ON `pams_developer`.`id`=:dev_id AND `pams_project`.`dev_id`=`pams_developer`.`id`";
$TotalSPAGDV = $GetReport->GetCount($TotalSPAGDVQuery,$dev_id);
?>
<div class="well">
<div class="reportTitle">Developer : <b><?php echo "$developer"; ?></b></div>
<div class="reportTitle">Total SPA Unit : <b><?php echo "$TotalSPAUnit"; ?></b></div>
<div class="reportTitle">Total SPA GDV : RM <b><?php echo "$TotalSPAGDV "; ?></b></div>
</div>
Form that send the data :
$('#submit').click(function(){
var ajaxRequest;
ajaxRequest = new XMLHttpRequest();
// this #developerSelect will get the value of the select option
var developer = $('#developerSelect').val();
console.log(developer); // this developer show "Tan & Tan Development in the log, worked fine "
var queryString = "developer=" + developer;
//this ajax-SPAGDVTotal.php is the php code that I show above
ajaxRequest.open("POST", "ajax-SPAGDVTotal.php", true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('AJAX_SPAResult');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
ajaxRequest.send(queryString);
The $developer can only show Tan but not full name Tan & Tan Developments.
Anyone can help me solve my problems ?
</div>