如何从与当前表连接的另一个表内部回显值

时间:2019-06-27 07:55:17

标签: php mysql

我有一个简单的问题,我无法解决 问题是我试图通过状态ID user_asset status 表内部与当前表 s_id 联接的值中回显一个值

我想回显状态名称,但它不断向我显示此错误

  

通知:未定义索引:D:\ wamp64 \ www \ Caprabia-test \ admin.php中的统计信息   在第104行

=============================================
|                user_asset                 |
=============================================
| id | category | code | userid | status_id | 
=============================================

====================
|   status table   |
====================
| s_id | stat_name |
====================

===========================
|   category table        |
===========================
| category_id | cate_name |
===========================

=============================================================================
|                                  user                                     |
=============================================================================
| user_id | first_name | last_name | email | password | dept | user_type_id |
=============================================================================

这是我的 php代码

$result = mysqli_query(
    $conn, 
    "select 
         user_asset.*, 
         user.first_name as fname, 
         user.last_name as lname,
         user.user_id, 
         user.dept,
         category.cate_name as titlecat, 
         status.stat_name as stat 
    from user_asset     
    inner join category on user_asset.asset_category = category.category_id     
    inner join user on user_asset.userid = user.user_id 
    inner join status on user_asset.status_id = status.s_id"
);

我的桌子

<table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped  display " width="100%">
    <thead>
        <tr >
            <th style="text-align:center"> الرقم </th>
            <th style="text-align:center">المستخدم</th>
            <th style="text-align:center">القسم</th>
            <th style="text-align:center">الصنف</th>
            <th style="text-align:center">الكود</th>
            <th style="text-align:center">التفاصيل</th>
            <th style="text-align:center">الحالة</th>
            <th style="text-align:center">لاعدادات </th>
        </tr>
    </thead>
    <tbody>

    <?php 
    $no = 1;
    while($row = mysqli_fetch_array($result)){
    ?>

        <tr>
            <td style="text-align:center"><?php echo $no;?></td>
            <td style="text-align:center">
                <a href="/Caprabia-test/view_user.php?id=<?php echo $row['user_id'];?>">
                    <?php echo $row['fname'];?>  <?php echo $row['lname'];?> 
                </a>
            </td>
            <td style="text-align:center"><?php echo $row['dept'];?></td>
            <td style="text-align:center"><?php echo $row['titlecat'];?></td>
            <td style="text-align:center"><?php echo $row['code'];?></td>
            <td style="text-align:center"><?php echo $row['title'];?></td>
            <td style="text-align:center"><?php echo $row['stat'];?></td>
            <td class="center" style="text-align:center">
                <a class="" href="edit_asset.php?idedit=<?php echo $row['asset_id'];?>" data-toggle="tooltip" title=" تعديل الاصل" > 
                    <i class="icon-edit"> </i>
                </a>
                <br>
                <a class=""href="move_asset.php?idmove=<?php echo $row['asset_id']?>" data-toggle="tooltip" title="نقل الأصل الى مستخدم اخر"> 
                    <i class="icon-move"> </i>
                </a>
                <br>
                <a class="" href="admin.php?idedelete=<?php echo $row['asset_id'] ?>"  onclick= "return checkDelete()" data-toggle="tooltip" title="ارشفة الاصل"> 
                    <i class="icon-trash"> </i>
                </a>
            </td>
        </tr>

        <?php $no++; ?>
    <?php }?>

    </tbody>
</table>

var_dump($row)的输出:

array (size=22)
    0 => string '1210' (length=4)
    'asset_id' => string '1210' (length=4)
    1 => string '9' (length=1)
    'asset_category' => string '9' (length=1)
    2 => string '564' (length=3)
    'code' => string '564' (length=3)
    3 => string 'ىلاةةيلاةلا' (length=22)
    'title' => string 'ىلاةةيلاةلا' (length=22)
    4 => string '19001' (length=5)
    'userid' => string '19001' (length=5)
    5 => string '1' (length=1)
    'status_id' => string '1' (length=1)
    6 => string 'احمد' (length=8)
    'fname' => string 'احمد' (length=8)
    7 => string 'نور' (length=6)
    'lname' => string 'نور' (length=6)
    8 => string '19001' (length=5)
    'user_id' => string '19001' (length=5)
    9 => string 'تقنية المعلومات' (length=29)
    'dept' => string 'تقنية المعلومات' (length=29)
    10 => string 'أجهزة كهربائية' (length=27)
    'titlecat' => string 'أجهزة كهربائية' (length=27)

0 个答案:

没有答案