douniwan_0025 2013-10-10 15:04
浏览 35
已采纳

显示数据库,方法,任何ci助手的查询结果?

UPDATE:

How could/would i be able to display the results. My mind is blocked, i cant seem to think coz all my mind prioritizes is the design/look of how it would be displayed. If someone could show me in code how to display each of the data, i would be able to finish.

I have little to no time to make a better database structure so one table would suffice. :)

Table columns: id name meal cuisine cooking difficulty description

Search View: 1st step

<h2>Results:</h2>

                <?php if($result == 0):?>
                No records found.
            <?php else:?>
                <?php foreach($result as $r):?>
                    <?=anchor('recipe_controller/show_recipe_search/'.$r->id,$r->name);?><br />
                <?php endforeach;?>
            <?php endif;?>
            <p>
                <?=$links?>
            </p>

Controller: 2nd step

public function show_recipe_search()
    {

    $to_show = $this->uri->segment(3);
    $this->db->where('id', $to_Show);
    $query = $this->db->get('recipe');
    $data['result'] = $query->result_array();

    $this->load->view('display_recipe',$data);

    }

View: 3rd step

<?php foreach($result as $r):?>
<h2><?php echo '$name'; ?></h2> // Recipe name
        <?=$r->echo rest of row;?><br />
                <?php endforeach;?>

Since my view is incomplete as my mind is rendering me paralyzed. IDK why. I just cant think of how i would be able to display the result. Should be easy but until i can picture the design i cant echo the results yet.

What does this error imply?

a php error was encountered

severity: notice

message: trying to get property of non-object

filename: views/display_recipe.php

line number: 63

line 63 is <h2><?php echo $r->name; ?></h2>

  • 写回答

1条回答 默认 最新

  • douqianmin5367 2013-10-10 20:57
    关注

    Your error is generally thrown when an object cannot access a property, due to it being null. I'd imagine that the main idea is that you're not actually returning anything from the DB.

    I suspect that your problem is on this line:

    $this->db->where('id', $to_Show);
    

    Can you try a var_dump() right after you execute your query or going through XDebug?

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

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题