php - 如何从 codeigniter 中的数据库表中获取特定值

标签 php mysql codeigniter

在我的数据库表中,我有一列包含这些数据

background: linear-gradient(top , rgb(255,104,0) 0% , rgb(255,68,0) 100%);
background: -o-linear-gradient(top , rgb(255,104,0) 0% , rgb(255,68,0) 100%);
background: -ms-linear-gradient(top , rgb(255,104,0) 0% , rgb(255,68,0) 100%);
background: -moz-linear-gradient(top , rgb(255,104,0) 0% , rgb(255,68,0) 100%);
background: -webkit-linear-gradient(top , rgb(255,104,0) 0% , rgb(255,68,0) 100%);

由此我只想要像

这样的 rgb 值
rgb(255, 104, 0) 0%  and rgb(255,68,0) 100%

我像这样用普通的 PHP 编写代码

SELECT * 
FROM dt_site_settings
WHERE NOT (
Button_Gradient_Background_Color LIKE  '%rgb%')

但它不能正常工作,我想要在 codeignter 模型中。

我该怎么做?

最佳答案

检查这个它在核心 PHP 中。

<?php 
   $color= "rgb(255,104,0)";
   $query = mysql_query("SELECT * FROM `dt_site_settings` WHERE Button_Gradient_Background_Color like '%$color%'");
   $data = mysql_fetch_array($query);
   $find = $data['Button_Gradient_Background_Color'];
   $ex =  explode(',',$find);
   $first_color = $ex[1].','.$ex[2].','.$ex[3];
   $second_color = $ex[4].','.$ex[5].','.$ex[6];
   echo '<br>'.$first_color .'<br>';
   echo '<br>'.$second_color .'<br>';
?>

关于php - 如何从 codeigniter 中的数据库表中获取特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33030936/

相关文章:

PHP 方法只能运行一次 [SQL]

php - 循环遍历数组并显示结果

php - 使用属性从类内部查询 mysql 数据库

php - 用于从不同表获取数据并将其用于距离计算的 MySQL 查询

mysql - mySQL 表上的多个联接

php - 用短代码替换 Woocommerce Storefront header

mysql - 我必须位于哪个工作目录才能连接到 R 中的 MySQL 服务器

php - Mysql 选择不同的多列循环遍历结果

php - 将数组传递给模型函数查询 codeigniter

apache - htaccess vhost codeigniter index.php