drxyaox153896 2018-04-16 02:51
浏览 55

显示数据库中的特殊字符[重复]

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); 

Image

The $developer can only show Tan but not full name Tan & Tan Developments.
Anyone can help me solve my problems ?

</div>
  • 写回答

1条回答 默认 最新

  • dqsvnsad79721 2018-04-16 04:03
    关注

    Maybe you can try this if you want to display the special characters:

    <?php echo htmlspecialchars($developer, ENT_QUOTES, 'UTF-8'); ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了