我如何将PHP原生转换为codeigniter代码 [英] How I convert PHP native into codeigniter code

查看:108
本文介绍了我如何将PHP原生转换为codeigniter代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!我需要帮助,我尝试创建搜索我的数据,但我不知道如何将我使用php native生成的代码转换为codeigniter方式。



检查我的代码:



Good Day! I need help, I tried creating search for my datas but I don't how I will convert the code I made using php native into codeigniter way.

Check my code:

<?php

if(isset($_POST['search']))
{
	$valueToSearch = $_POST['valueToSearch'];
	$query = "SELECT * FROM user where CONCAT(user_id, user_name, fname, lname) like '%".$valueToSearch."%'";
	$search_result = filterTable($query);

}
function filterTable($query)
{
	$connect = mysqli_connect("localhost", "root", "dbjireh", "exercise");
	$filter_Result = mysqli_query($connect, $query);
	return $filter_Result;

}

?>

<!DOCTYPE html>
	<title>test search
	
	table,tr,th,td
	{
		border: 1px solid black;
	}
	
		<br><br>

		
						<?php while ($row = mysqli_fetch_array($search_result)):?>
							
						<?php endwhile;?>
		<table><tbody><tr>				<th>Username</th>				<th>Firstname</th>				<th>Lastname</th>			</tr><tr><td><?php echo $row['user_name'];?></td>			<td><?php echo $row['fname'];?></td>			<td><?php echo $row['lname'];?></td>			</tr></tbody></table>





我有什么尝试过:



我尝试将其转换为codeigniter这里是我的代码:





What I have tried:

And I tried to convert it into codeigniter here's my code :

<!DOCTYPE html>
	<title>test search
	
	table,tr,th,td
	{
		border: 1px solid black;
	}
	
		<br><br>
          
          <!--get datas into database and display it on this page-->
    <?php foreach ($datas as $data) : ?>
            <!--edit and delete button-->
            <?php endforeach;?> 
          
          
      <table><thead><tr><th>Username</th>            <th>First Name</th><th>Last Name</th></tr></thead><tbody><tr>    <td><?php echo $data->user_name;?></td>    <td><?php echo $data->fname;?></td>    <td><?php echo $data->lname;?></td><td><a href="<?php echo $data->user_id;?>" class="btn btn-success btn-sm"><span class="glyphicon glyphicon-pencil"></span> Edit </a></td>        <td><a href="<?php echo $data->user_id;?>" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span> Delete </a></td>    </tr></tbody></table>

推荐答案

_POST [ ' search']))
{
_POST['search'])) {


valueToSearch =
valueToSearch =


_POST [' valueToSearch ];
_POST['valueToSearch'];


这篇关于我如何将PHP原生转换为codeigniter代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆