Search code examples
phpmysqldatabasecoordinates

how I can show position of an object ( a mark) which have coordinate on database with PHP


I have a database and there is writing point numbers, x and y pixsel coordinates. I want to show that points on webpage. I can show only one point (last one).

How I can show all of them on webpage in sametime?

can anyone help me? where is the my mistake?

<?php
ob_start();

$image = imagecreatetruecolor(800, 600);
$red = imagecolorallocate($image, 250, 0, 0);

$con=mysqli_connect("localhost","root","xxxxxx","yyyyy");
$result=mysqli_query($con,"SELECT * FROM points"); 
mysqli_set_charset($con, "utf8");

while($select=mysqli_fetch_array ($result)) 

$id = $select['id'];
$x = $select['x'];
$y = $select['y'];

for ( $i=0; $i < count($x); $i++ ) 
imagefilledellipse($image, $x[$i], $y[$i], 10, 10, $red);


header( 'Content-type: image/jpeg' );
ob_end_flush(); 
ob_end_clean(); 
imagepng( $image );

?>

Solution

  • Maybe provide more information on this topic.

    This might help you? https://www.php.net/manual/en/function.imagesetpixel.php