Jump to content

Quick Help - Php with MYSQL Query


summerpewp

Recommended Posts

I'm trying to do php and query some information. But it seems that i'm running into an issue.

 

Here is my code:

<?php 
	include('db.php');
	$location = mysql_query("SELECT * FROM player");
	$row = mysql_fetch_array($location);

	$newx = $row['player_loc_x']-1;
	$y = $row['player_loc_y'];
	$z = 1;
	$border = mysql_query("SELECT * FROM zones WHERE zone_id = '1' && zone_b_x = '$newx'");
	$row2 = mysql_fetch_array($border);
	$zonebx = $row2['zone_b_x'];
	$zoneby = $row2['zone_b_y'];


	if ( $newx == $zonebx && $y = $zoneby )
	{
	$_SESSION['$errormsg'] = 1;
	header("Location: ../index.php");
	}
	else {
	$_SESSION['$errormsg'] = 0;
	mysql_query("UPDATE player SET player_loc_x = '$newx'
WHERE player_id= '1'");

	header("Location: ../index.php");
	};
?>

 

What i'm trying to do is fetch some information from Mysql that meets both requirements in the IF statement. I have many that meet the first criteria but not the second. If it meets both then it proceeds, otherwise it fails. Right now, its reading it wrong .

 

For instance, in my database i have stored:

 

16, 8

16, 9

16, 10

 

it only responds to 16, 8 and doesn't recognize that 16,9 and 16,10 are still needing a check.

 

I'm not sure if i am unclear on what I'm trying to describe so please ask any more questions if need be.

 

I know the code is probably not up to standards, but i'm just learning php / mysql now so forgive the noob code.

Link to comment
https://forums.phpfreaks.com/topic/181557-quick-help-php-with-mysql-query/
Share on other sites

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.