dqask02082 2011-12-06 00:47
浏览 19
已采纳

2 if else语句和2种不同的$类型[关闭]

Basically I am working a site store and having problems with it. Nothing online seems to have what I need to figure out. I am having the first if else statement working fine and the second not working properly. Here is the coding tell me what is wrong or what I can do different.

<?php
$adsql = mysql_query("SELECT * FROM store_items WHERE userid='$id2'");
while($adrow = mysql_fetch_array($adsql)){
    $type = $adrow['type'];(this is int)
                               $item = $adrow['id'];
    if ($type == 1) {
        $item1 = "<center>You have bought this already</center>";
    } else {
        $item1 = This is where item1 is bought

            }
    if ($type == 2) {
        $item2 = "<center>You have bought this already</center>";
    } else {
        $item2 = This is where item2 is bought
            </table>
            ";
              }
      }
    ?>

Its retrieving the last number not all the numbers which in return only showing 1 of if else statements instead of both. Any idea what is wrong be a appreciated.

  • 写回答

1条回答 默认 最新

  • drbxr86044 2011-12-06 00:53
    关注

    The lines:

    $item1 = This is where item1 is bought
    

    and

    $item2 = This is where item2 is bought
    

    Should be:

    $item1 = "This is where item1 is bought";
    

    and

    $item2 = "This is where item2 is bought";
    

    Without the quotes, the statements are syntactically incorrect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本