用php查询mysql行

您好朋友我的问题是我有一些Excel表上传到数据库,然后数据将检索并张贴在一个Web门户。

我的问题是我无法查询特定的数据,这是在这张图片标记

任何人都可以帮助我只查询数字[所有]没有'%',并将其分配给一个variables…..

<?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% 

您可以使用trimfunction,摆脱'%'字符。

我编码以下testing:

 $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; 

SQL小提琴: http ://sqlfiddle.com/#!2/bf0b2/5

键盘: http : //codepad.viper-7.com/fmw59H (更新)