| 
	
 | 
 Posted by chsadaki on 06/23/06 08:06 
Erwin Moller wrote: 
> chsadaki@hotmail.com wrote: 
> 
> > 
> > Erwin Moller wrote: 
> >> chsadaki@hotmail.com wrote: 
> >> 
> >> > Hello.... 
> >> > 
> >> > I'm working on a page that finds the shortest path between two nodes. 
> >> > The problem is when I draw a node on the map(in the administrative 
> >> > page) to save it later in a mysql table, the node doesn't appear unless 
> >> > I press the refresh button of the borwser... 
> >> > 
> >> > this is the code that i worte 
> >> 
> >> Hi, 
> >> 
> >> It loos like you are mixing PHP and JS in a bad way. 
> >> Look at the HTML-source your PHP produces, especially the 
> >> onClick-handler. It is not valid. 
> >> 
> >> > 
> >> > function drawNode($drawMode){ 
> >> > 
> >> > $x=$_GET[img_x]; 
> >> > $y=$_GET[img_y]; 
> >> > $map=imagecreatefromjpeg("nodedMap.jpg"); 
> >> > $Black=imagecolorallocate($map,0,0,0); 
> >> > $drawMode=''; 
> >> > imagefilledarc($map,$x,$y,10,10,0,360,$Black,IMG_ARC_PIE); 
> >> > imagejpeg($map,"nodedMap.jpg"); 
> >> > mysql_query("insert into nodeinfo values ('',$x,$y)"); 
> >> > return ; 
> >> > } 
> >> > 
> >> > and i call this function by this insturction: 
> >> > 
> >> >  <input name="img" type="image" src="nodedMap.JPG" width="569" 
> >> > height="290" border="0" onClick="<? drawNode($drawMode); ?> " > 
> >> 
> >> 
> >> Regards, 
> >> Erwin Moller 
> > 
> > 
> > so how can I make it work in a good way?? 
> 
> Hi, 
> 
> First understand what is executed when, then fix it. :-) 
> PHP delivers HTML (and possibly also images) to an internetbrowser. 
> The internetbrowser doesn't care at all where the HTML originated from (PHP, 
> plain HTML stored in a file, random noise, etc). 
> So you must first decide WHAT html you want to deliver, and you can always 
> check it by looking at the source (rightmousebutton on the page, select 
> 'view source'). 
> This is always the first step if your webpage isn't doining what you expect 
> it to and is generated dynamically by PHP (or every language for that 
> matter) 
> 
> I am unsure what you expect of your program. 
> 
> COnsider the following code: 
> <input name="img" type="image" src="nodedMap.JPG" width="569" 
>  height="290" border="0" onClick="<? drawNode($drawMode); ?> " > 
> 
> This will execute your drawNode function, every time the script is executed. 
> Simply because you put the functioncall in a place where it is always 
> execute. 
> Also, it is meaningless to place in an onCLick-event, because the fact that 
> somebody clicks it in the browser has nothing to with the fact that the 
> function was executed by PHP when creating the HTML. 
> 
> If you want to solve your problem: 
> 1) Make sure you understand what is executed where. 
> 2) learn how to pass x/y coordinates to the server. 
> Here is a link to get started: 
> http://www.plus2net.com/php_tutorial/php_image_coordinates.php 
> 
> Hope this helps. 
>  
> Regards, 
> Erwin Moller 
 
 
Thanx a lot.  
Chamirame Sadaki
 
  
Navigation:
[Reply to this message] 
 |