Jump to content

retrieve single result from 2d mysql matrix with x and y being variables


artoak

Recommended Posts

Hello

 

I am trying to write some code to retrieve a single result from 2d mysql matrix with x and y being variables input by the user. I can do it that I can select any row from the 1st column and then hard code how many columns across I want.

 

$pitch=$_POST['field_3'];
$direction=$_POST['field_4'];

$a_pitch="SELECT * FROM angle WHERE pitch='$pitch'";
$result=mysql_query($a_pitch);

// Search the database 'angle' for the corrolating factor

if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_row($result)) {
//		echo $row[1]."<br/>";
	$orientationf=$row[2];
}}

 

So the $row[2] need to be a variabe called up in $direction. I thought I could replace $orientationf=$row[2] with $orientationf=$row[$direction] but no. Do I need a fetch_column inside the fetch_row but I've tried different things and my head is starting to bleed.

 

Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.