dongmou3615 2017-03-30 11:17
浏览 50
已采纳

在home_v.php页面中单击“添加学生”按钮,打开另一个视图页面user_v.php

<html>
<head><head>
<title>Home Page</title>
<body>
<style>
.looks
{
border:1px solid black;
}
</style>
<center><h1>Welcome Students!</h1><br><br></center>
<span style="float: right;">
<a href="<?php echo site_url().'/user_c/logout' ?>">Logout</a>      
</span>
<h2>List of Students in system are : </h2>
<div id="list">
<table class='looks'>
<tr><th>Student Name</th>
<th></th><th></th><th></th></tr>
<?php
    foreach ($list->result() as $row)
    {
    echo "<tr>";
    echo "<td style='width:30%'>".$row->name."</td>";
    echo "<td><input type='submit' value='Add Student' style='float:left' 
    onclick="site_url().'/user_c/add'"></td>";
    echo '<td><input type="submit" value="Update Student" 
    style="float:left"></td>';
    echo '<td><input type="submit" value="Delete Student" 
    style="float:left"></td>';
    echo "</tr>";      
    }
?>
</table>
</div>
</body>
</html>

Parse Error

The foreach loop is executed and the values of student are displayed on the home_v.php page. Besides the names of these students, I have added a button (Add Student).On clicking this button I want to open another view page user_v.php, for which I have used onclick tag in the button. But it is not working and I get the error attached below. Kindly help as what is the mistake I am making.

    //controller
    function add()
    {
        $this->load->view('user_v');
    }
  • 写回答

1条回答 默认 最新

  • duano3557 2017-03-30 11:49
    关注

    You are making mistake in concatenating PHP and HTML data. And to make it work on the click do following changes:

    echo "<td><input type='submit' value='Add Student' style='float:left' 
    onclick=window.location='". site_url("user_c/add")."'></td>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制