朋友们,我的问题是我有一些excel表格上传到数据库,然后将检索并发布到门户网站上。
我的问题是我无法查询此图片中标记的特定数据
任何人都可以帮我查询没有'%'的数字[全部]并将它们分配给变量.....
<?php
$con = mysql_connect("localhost","root","");
if(!$con)die (msql_error());
$db = mysql_select_db("csv");
if(!$db) die(mysql_error());
$query = mysql_query("select * from users");
$rows = mysql_fetch_array($query);
______________________________________________________
**if i have column like this how to extract only 1,12,14,60,4 ? without '%'
and also remove first row "High value %" and post them in this format
$output = array(1,12,14,60,4)**
______________________________________________________
High value%
1%
12%
14%
60%
4%
答案 0 :(得分:0)
您可以使用trim
功能来摆脱&#39;%&#39;字符。
我编写了以下测试代码:
$test = "15%";
echo trim($test,"%");
----------FULL TEST--------------
$test = "15%"; //test case
echo "Test:".trim($test,"%")."</br>";
$rows = array('1%','2%','3%');
$aux = array();
foreach($rows as $key)
{
echo trim($key,"%")."</br>"; //just output
$aux[] = trim($key,"%"); //or transforming
}
var_dump($aux);
Mysql版本:
set @test = "15%";
select trim(BOTH '%' FROM @test);
#Retrieve all rows but first
select name,trim(BOTH '%' FROM lastname) as normal,trim(BOTH '%' FROM email) as high
from users limit 1,1000;
#select row based on Normal %
select name, trim(BOTH '%' FROM lastname) as normal,trim(BOTH '%' FROM email) as high
from users
where trim(BOTH '%' FROM lastname) = 5;