Greetings!
Please be so kind and take a few minutes, I believe any mind other than
mine can solve this. I am writing a game. As you wander through the
gameworld, you may come upon signs. I have a DB where the signs are
listed, with "longitude" and "latitude". Anytime someone takes a step,
I want to show a grid where any square can be reached within 3 steps.
And if there's a sign in one grid, I want to show it, so the player can
walk directly to it.
In my test environment I have three signs located very close and around
to 100|50. The routine I wrote below works. But it only gives me the
last of the three signs. And I just can't tell if it's a logical
problem with my two loops and the foreach, or if there's a hook with
PHP itself.
So why does it only show me the last of the three signs????
Also, how can I make this with POST?
And I know this is messy, how could I make it faster?
I am grateful for any pointer!
Helpless regards, Gilbert.
PS: $lire is for x, $raru is for y
<pre>
$signr = $db->get_results("S ELECT text,longitude, latitude FROM signs
WHERE longitude>$lire-4 and longitude<$lire +4 and latitude>$raru-4 and
latitude<$raru+ 4",ARRAY_A);
for ($j = 3 ; $j <= 9 ; $j++) {
for ($i = 3 ; $i <= 9 ; $i++) {
$cps[$i][$j] = "<td width=30 height=30 align=center valign=center>< a
href='main.php? dir=$i$j'><img src='images/";
$icon = "gravel.gif ";
if (is_array($sign r)) {
reset($signr);
foreach($signr as $check) {
$x = $lire+$i-6;
$y = $raru+$j-6;
if ($check['longitude'] == $x && $check['latitude'] == $y ) {
$icon = "scroll.gif ";
}
else $icon = "gravel.gif ";
}
}
$cps[$i][$j] .= $icon;
$cps[$i][$j] .= "' style='border:2 px outset black'
border=0></a></td>";
}
}
// $cps[6][6] = "<td></td>";
$compass = "<form action='main.ph p' method='POST'>" ;
$compass .="<table cellspacing=0 cellpadding=0
background='ima ges/xmap.jpg'>";
$compass .= "<tr><td></td><td></td><td></td> ".$cps[6][3]."
<td></td><td></td><td></td></tr>\n";
$compass .= "<tr><td></td><td></td>
".$cps[5][4].$cps[6][4].$cps[7][4]."<td></td><td></td></tr>\n";
$compass .= "<tr><td></td>
".$cps[4][5].$cps[5][5].$cps[6][5].$cps[7][5].$cps[8][5]."<td></td></tr>\n";
$compass .=
"<tr>".$cps[3][6].$cps[4][6].$cps[5][6].$cps[6][6].$cps[7][6].$cps[8][6].$cps[9][6]."</tr>\n";
$compass .= "<tr><td></td>
".$cps[4][7].$cps[5][7].$cps[6][7].$cps[7][7].$cps[8][7]."<td></td></tr>\n";
$compass .= "<tr><td></td><td></td>
".$cps[5][8].$cps[6][8].$cps[7][8]."<td></td><td></td></tr>\n";
$compass .= "<tr><td></td><td></td><td></td> ".
$cps[6][9]."<td></td><td></td><td></td></tr>\n";
$compass .= "</table></form>";
unset($cps);
</pre> 1 1558
I wrote that part again. This time the $cps is premade, and I only
foreach $signr and replace the $cps where necessary. Learning by
doing...
Thanks anyway to anyone who read it.
Greets, Gilbert. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: whirl |
last post by:
Hi.
I really need some help on this one please.
I am trying to print a 12.1 x 12.1cm box to my printer.
I have found this code bit I just cant work out what the numbers mean. I
know they are something to do with X/Y coordinates but what do the values
actually mean .
Printer.Line (1000, 2000)-(5000, 4000), vbRed, B
|
by: Martin Bless |
last post by:
Why can't we have an additional 'print' statement, that behaves
exactly like 'print' but doesn't insert that damn blank between two
arguments?
Could be called 'printn' or 'prin1' or 'prinn' anything similar you
like.
Would make my life so much easier. Often I start with a nice and short
print statement, then there happen to be more arguments and neat
formatting becomes more important and as a result I find myself
|
by: Martin |
last post by:
Due to the the large numbers of MS trained programmers unemployed we are
looking at using MS Development environments.
VB programmers are currently 10 a penny.
However I find C a bit more logical as I come from a Clipper background.
Current;y .NET seems to be the latest fashion, so what is it about and
should we use it please?
|
by: WindAndWaves |
last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one
of those NEVER USE.
I can understand that it may lead to confusing code, but I often use it like
this:
is this wrong?????
Function x
select case z
|
by: Christopher Benson-Manica |
last post by:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
| |
by: Sathyaish |
last post by:
Hi friends,
I am beginning to practice C from K&R. Although I am only familiar
with the language, this time I want to invest time learning it
thoroughly. I've written this practice excercise program to replace
more than a single blank in an input with only a single blank in the
output. Here's the code.
#include <stdio.h>
|
by: steroche |
last post by:
I would REALLY appreciate help please please please! Im sure it is
probably blindingly obvious to most of you but I am totally in the dark
here!I am lost - i thought i had finally figured out this dataSet
updating lark when i realised that i think i am right back at square
1!!!
Here's my scenario - i have a SQLDB and i retrieve all my data from
that into a dataset and display this to a datagrid(WebForm). I have got
this grid sorted and...
|
by: serge |
last post by:
How can I run a single SP by asking multiple sales question either
by using the logical operator AND for all the questions; or using
the logical operator OR for all the questions. So it's always
either AND or OR but never mixed together.
We can use Northwind database for my question, it is very similar
to the structure of the problem on the database I am working on.
IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL
DROP TABLE REPORT_SELECTION
|
by: bbawa1 |
last post by:
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells.Text)>=15))&&(Convert.ToInt32(e.Row.Cells.Text)>=17);
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |