dongxiejie9387 2010-11-08 11:29 采纳率: 100%
浏览 90
已采纳

在PHP echo中嵌入javascript

echo "<td> + manuf + </td>";

Is this above ever going to work??

I'm pulling results from a mysql db to edit the contents but need the jQuery functionality to edit it, hence the embedded javascript variable...

EDIT:

Sorry for the lack of context, its related to another question i've asked on here Mysql edit users orders they have placed this is the end goal. To edit the order i place, i need to pull the results into an environment similar to how the user placed the order. So my thinking was to include the jQuery functionality to add items to a cart etc, then they could press submit and in the same way i used .Ajax to post the data to an insert php script i would post the values to an update php script! Is this backwards thinking, any advice welcomed!

  • 写回答

7条回答 默认 最新

  • dsgk40568 2010-11-08 11:48
    关注

    I suggest you take a look at the follwing.

    Now your simplest solution under you circumstances is to do go for the json_encode method. Let me show you an example:

    $json_data = array(
        'manuf' => $some_munaf_data
    );
    
    echo "<script type=\"text/javascript\">";
       echo "var Data = " . json_encode(json_data);
    echo "</script>";
    

    This will produce an object called Data, and would look like so:

    <script type="text/javascript">
    var Data = {
        munaf : "You value of $some_munaf_data"
    }
    </script>
    

    Then when you need the data just use Data.munaf and it will hold the value from the PHP Side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭