duanpu6319 2010-01-22 03:30
浏览 13
已采纳

仅使用PHP mail()发送填充字段

I'm finishing up an online menu for a fine dining client. For each item, the user can enter the desired quantity.

When the user finishes selecting and submits the form, I want a confirmation email to go to the user and to the restaurant owner (the same message).

In the confirmation email, I only want to display items for which they've entered a quantity. E.g.:

Foie Gras 1 $9ea
Steak au Poivre 2 $37ea

I know this is probably straightforward, but I can't conceptualize at what point the script checks for something like !="". Or something.

Here's the menu for your reference: http://www.greenroomgrille.com/valentines/

Thanks so much in advance.

  • 写回答

3条回答 默认 最新

  • dongxia2068 2010-01-22 03:34
    关注

    You could run through a foreach and concat the values that have quantities:

    $order = "";
    foreach ($items as $item => $quantity) {
      if ($quantity > 0)
        $order .= "{$item} {$quantity}
    ";
    }
    print $order;
    

    This assumes an array like this:

    $items = array("Pudding" => 3, "Yogurt" => 12, "Soup" => 0, "Apples" => 0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题