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 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝