noirsith Posted July 24, 2008 Share Posted July 24, 2008 Right now I can query my table as an array (mysql_fetch_array) and output all the data into a table I create. However if I just wanted to get the data from Column 2, Row 1 of a table in my database and output it not into a table but just as is, is there a way to do that? Thank you much. Link to comment https://forums.phpfreaks.com/topic/116440-solved-getting-data-from-a-particular-column-and-row-in-a-table/ Share on other sites More sharing options...
.josh Posted July 24, 2008 Share Posted July 24, 2008 Yes, you can do that with mysql_result(). You can either do a blanket $sql = "select * from table"; $result = mysql_query($sql); $row = 0; // row 1 cuz it starts at 0 $col = 1; // col 2 cuz it starts at 0 $val = mysql_result($result, $row, $col); But that's not really very efficient unless you're wanting to be able to grab multiple pieces of data and the "x,y coords" are variable. If you're looking for retrieving just 1 cell in a table, you should write your query string to return only that cell to begin with. Example: tNames id name 0 John 1 Mary 2 Jane 3 Mike $sql = "select name from tNames where id = 1"; $result = mysql_query($sql); $name = mysql_result($result, 0, 0); Link to comment https://forums.phpfreaks.com/topic/116440-solved-getting-data-from-a-particular-column-and-row-in-a-table/#findComment-598828 Share on other sites More sharing options...
noirsith Posted July 24, 2008 Author Share Posted July 24, 2008 Thank you so much, I am able to get data now. Much appreciated. Link to comment https://forums.phpfreaks.com/topic/116440-solved-getting-data-from-a-particular-column-and-row-in-a-table/#findComment-598882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.