[英]pulling from a specific data from a row and column in a database
My data base looks like this. 我的数据库看起来像这样。 its ordered ascending by NO# And col2 is the start of the database NO# is basically invisible and only used as a reference as to row number so lets say I wanted to display on a web page the text in col8, row 5. What would the php code be?
它按NO#升序排列,而col2是数据库的开始NO#基本是不可见的,仅用作行号的参考,因此可以说我想在网页上显示col8中第5行的文本。 PHP代码是吗?
PS. PS。 the connect code is seperate and not an issue hence i did not include itI
连接代码是单独的,不是问题,因此我没有包括它
-|NO#|col2|col3|col4|col5|col6|col7|col8|col9|col10
---------------------------------------------------
|1 | | | | | | | | | |
---------------------------------------------------
|2 | | | | | | | | | |
---------------------------------------------------
|3 | | | | | | | | | |
---------------------------------------------------
|4 | | | | | | | | | |
---------------------------------------------------
|5 | | | | | | |2012| | |
---------------------------------------------------
|6 | | | | | | | | | |
---------------------------------------------------
|7 | | | | | | | | | |
---------------------------------------------------
|8 | | | | | | | | | |
---------------------------------------------------
|9 | | | | | | | | | |
---------------------------------------------------
|10 | | | | | | | | | |
---------------------------------------------------
Here is my code but it whites out the page when I try to load it. 这是我的代码,但是当我尝试加载页面时,它会使页面变白。
<?php
//selects row
$query = "SELECT * FROM `Inventory` WHERE NO# = '5'";
//select column
$col8 = $row['col8'];
// fetch the results
WHILE($row = mysql_fetch_array($query):
$row = mysql_fetch_array($result);
// display the results
<div id="year">echo "$col8";</div>
?>
I would probably do something like what's below. 我可能会做下面的事情。 I have not tested this code, though.
不过,我尚未测试此代码。
<?php
$result = mysql_query( "SELECT `col8` FROM `Inventory` WHERE `NO#` = '5' LIMIT 1" );
$row = mysql_fetch_assoc( $result );
?>
<div id="year"><?php echo $row['col8']; ?></div>
Hopefully that'll help you out a bit. 希望能对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.