if it saying some error, lets check and correct them 🙂 i've not tested ...
this is the database structure:
CREATE TABLE coordinates (
id int(6) NOT NULL auto_increment,x int(11) NOT NULL, y int(11) NOT NULL, longitude_latitude int(11) NOT NULL
,PRIMARY KEY (id),
UNIQUE KEY id (id)
) TYPE=MyISAM AUTO_INCREMENT=1;
If you want to select a value for x and y, you will get like this:
<?
error_reporting(E_ERROR | E_PARSE);
ini_set("display_errors", 1);
include("connect.php"); //lets connect to the database...
if($_POST)
{
$x = (int)($_POST['x']);
$y = (int)($_POST['y']);
$query="SELECT * FROM coordinates WHERE x=$x AND y=$y";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
if ($num > 0 ) {
$i=0;
while ($i < $num) {$x = mysql_result($result,$i,"x");
$y = mysql_result($result,$i,"y");
$longitude_latitude = mysql_result($result,$i,"longitude_latitude");
$id = mysql_result($result,$i,"id");
echo "<b>x:</b> $x<br>";
echo "<b>y:</b> $y<br>";
echo "<b>longitude_latitude:</b> $longitude_latitude<br>";
echo "<br><br>";
$i++; } } else { echo "No match"; }
}
?>
Select the x and y coordinates:<br>
<form id="FormName" action="?" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0"><tr><td width = "150"><div align="right"><label for="x">x</label></div></td>
<td><input id="x" name="x" type="text" size="25" value="<?=$_POST["x"]?>" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="y">y</label></div></td>
<td><input id="y" name="y" type="text" size="25" value="<?=$_POST["y"]?>" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="longitude_latitude">longitude_latitude</label></div></td>
<td><input id="longitude_latitude" name="longitude_latitude" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width="150"></td><td>
<input type="submit" name="submitButtonName" value="Add"></td>
</tr></table></form>
...html here....
bigdaddysheikh;10891022 wrote:Hey guys,
I am trying to develop an application but am confused on how I can develop the database structure. The information that is being inserted in the database is from a numerical graph with information from X and Y axis.
For example cell x:1, y:1 = 5, x:1, y:2 =10. I then want to extract the value by selecting those cooardinates. So for example, when I find x:1 y:1, the result should be 5. I was going to make a simple database but am confused on how I can relate the values of the x,y together?
Thanks in advance.