Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert values in a recordset.

Status
Not open for further replies.

rrhandle8

Programmer
May 9, 2008
10
US
I need a function that will loop through a recordset that has 3 fields, change the value of the number in the second column, and return the recordset so I can create a chart with it.

I've tried a number of different options, but there are problems with all the solutions I have tried so I decided not to confuse you by including all the different version of code I have written.

So, if I pass $rs to a function, how should I loop through it so I can return a different value for the second column which is named $rs['High']?
 
assuming you want to increase the value of High by one each time, here is some code. you can easily change the manipulation as you require

Code:
//example
$rs = mysql_query($sql);
$parsedOutput = parseRS($rs);

	function parseRS(&$rs){
		$output = array();
		while ($row = mysql_fetch_assoc($rs)){
			$row['High']++;
			$output[] = $row;
		}
		return $output;
	}
 
Thanks for the reply.

I forgot to mention I am using ODBC. I tried odbc_fetch_assoc, but it appears there is no such thing.

Is there another way to do this?
 
check the manual. odbc_fetch_array().

if this is not available on your system, just use one of the other odbc_fetch or odbc_result functions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top