PHP只检索一列的值 [英] PHP retrieve the values of only one column

查看:49
本文介绍了PHP只检索一列的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想只检索mysql中一列的值,并使用这些值绘制图形。我知道如何回应这些价值观。但是,我无法单独写出来。假设我有一张叫做汽车的桌子。它有一个用于汽车vin的列和一个用于品牌的列和一个用于价格的列。我只想检索价格列,并使用这些数字绘制条形图。

因此,X轴显示条形1,2,3 ......条形长度显示价格。我知道如何绘图,但我无法从该列中检索数字。请帮助。

I want to only retrieve the values of one column in mysql and use these values to plot a graph. I know how to echo these values. However, I am unable to write them seperately. Let''s say I have a table called cars. It has a column for car vin and a column for brand and a column for price. I just want to retrieve the column for the price and use these numbers to plot a bar graph.
So the X-axis shows bar 1, 2, 3 ... and the bar length shows the price. I know how to graph but I cannot retrieve the numbers from that column. Please help.

推荐答案

您好。


MySQL只返回您放入SELECT语句的那些列。除非你使用外卡字符(*),否则它将返回所有字符。


例如:
Hi.

MySQL will only return those columns you put into the SELECT statement. Unless you use the wild card character (*), in which case it will return all of them.

For example:
展开 | 选择 | Wrap | 行号


谢谢Ati

我按照你的意思显示或回显结果:

第1行:15行2 :18Row 3:26Row 4:14Row 5:54Row 6:31

但是,我想在另一个数组中使用这些值。我该如何检索它们。

我的数组是这样的:

Thanks Ati
I got it working to display or echo the results as you see:
Row 1: 15Row 2: 18Row 3: 26Row 4: 14Row 5: 54Row 6: 31
However, I want to use these values in another array. How do I retrieve them.
my array is like this:


data =(1 => somenumber1,somenumber2,somenumber3 ....) ;

somenumber实际上是一个数字。我只是写了一些数字

如何更换这些somenumbers?我回应的那一列的值。

像somenumber1应该是第1行的值

和somenumber2应该是第2行的值

请记住:我想在while循环之外使用这些值。

感谢您的帮助。
data=(1=> somenumber1, somenumber2, somenumber3 ....);
somenumber is really a number. I just wrote as somenumber
How do I replace these "somenumbers" with the value of that column that I echoed.
Like somenumber1 should be the value of Row 1
and somenumber2 should be the value of Row 2
Remember: I want to use these values outside the while loop.
Thanks for your help.


这篇关于PHP只检索一列的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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