patrickking04 Posted March 5, 2009 Share Posted March 5, 2009 Hi all, Right I have a map of the school I work at as the back ground picture and then loads of transparent boxes over certain areas. A student then would click the area (box) where they are being bullied and then it would add a +1 to mysql field to the correspondent area (box). How would I set an image to add +1 to a mysql field? any help would be great. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/ Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 generate a link with a variable for each image, with the variable being the id of the image hot spot, just send that to your processing form eg <a href='processbully.php?id=1><img src='hotspot.gif'/></a> Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777180 Share on other sites More sharing options...
patrickking04 Posted March 5, 2009 Author Share Posted March 5, 2009 is it possible for an example please Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777182 Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 <MAP NAME="map1"> <AREA HREF="processbully.php?id=1" ALT="Area 1" TITLE="Area1" SHAPE=RECT COORDS="6,116,97,184"> <AREA HREF="processbully.php?id=2" ALT="Area 2" TITLE="Area2" SHAPE=CIRCLE COORDS="251,143,47"> <AREA HREF="processbully.php?id=3" ALT="Area 3" TITLE="Area3" SHAPE=POLY COORDS="150,217, 190,257, 150,297,110,257"> </MAP> if you post a bit of your image map code I will show you what I mean if you still not sure Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777187 Share on other sites More sharing options...
patrickking04 Posted March 5, 2009 Author Share Posted March 5, 2009 Heres the code so far. also im using Serif Webplus x2 <?php include 'connect.php'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <title>Home</title> <style type="text/css"> <!-- body {margin: 0px; padding: 0px;} a:link {color: #2c3651;} a:visited {color: #1f5b8b;} a:hover {color: #2c3651;} a:active {color: #2c3651;} --> </style> <script type="text/javascript"><!-- var blankSrc = "wpscripts/blank.gif"; --></script> <script src="wpscripts/jspngfix.js" type="text/javascript"></script> </head> <body text="#000000" style="background: #ffffff; text-align:center; height:1000px;"> <div style="background: transparent; position:relative;width:750px;height:1000px;margin-left:auto;margin-right:auto;"> <div style="position:absolute; left:43px; top:21px; width:677px; height:967px;"> <img src="wpimages/Map.jpg" width="677" height="967" border="0" id="Site_Map" name="Site_Map" title="" alt=""></div> <div style="position:absolute; left:104px; top:203px; width:14px; height:152px;"> <img src="wpimages/Math_corri.png" width="14" height="152" border="0" id="Math_corri" name="Math_corri" title="" alt="" onload="OnLoadPngFix()"></div> <div style="position:absolute; left:118px; top:310px; width:24px; height:210px;"> <img src="wpimages/Science_corri.png" width="24" height="210" border="0" id="Science_corri" name="Science_corri" title="" alt="" onload="OnLoadPngFix()"></div> <div style="position:absolute; left:105px; top:520px; width:24px; height:139px;"> <img src="wpimages/Human_corri.png" width="38" height="139" border="0" id="Human_corri" name="Human_corri" title="" alt="" onload="OnLoadPngFix()"></div> <div style="position:absolute; left:130px; top:634px; width:140px; height:27px;"> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777204 Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 <div style="background: transparent; position:relative;width:750px;height:1000px;margin-left:auto;margin-right:auto;"> <div style="position:absolute; left:43px; top:21px; width:677px; height:967px;"> <a href="bullyprocess.php?id=1"><img src="wpimages/Map.jpg" width="677" height="967" border="0" id="Site_Map" name="Site_Map" title="" alt=""></a></div> <div style="position:absolute; left:104px; top:203px; width:14px; height:152px;"> <a href="bullyprocess.php?id=2"><img src="wpimages/Math_corri.png" width="14" height="152" border="0" id="Math_corri" name="Math_corri" title="" alt="" onload="OnLoadPngFix()"></a></div> <div style="position:absolute; left:118px; top:310px; width:24px; height:210px;"> <a href="bullyprocess.php?id=3"><img src="wpimages/Science_corri.png" width="24" height="210" border="0" id="Science_corri" name="Science_corri" title="" alt="" onload="OnLoadPngFix()"></a></div> <div style="position:absolute; left:105px; top:520px; width:24px; height:139px;"> <a href="bullyprocess.php?id=4"><img src="wpimages/Human_corri.png" width="38" height="139" border="0" id="Human_corri" name="Human_corri" title="" alt="" onload="OnLoadPngFix()"></a></div> <div style="position:absolute; left:130px; top:634px; width:140px; height:27px;"> </div> Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777210 Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 As for the update if the id numbers correlate to your id numbers in your database, then you simply query the database for the last value for that area add 1 to it and then update the entry. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777214 Share on other sites More sharing options...
patrickking04 Posted March 5, 2009 Author Share Posted March 5, 2009 How would i go about linking that into mysql? i have only every like form summit to mysql and pulled info from mysql. what would i have to include in processbully.php Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777217 Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 processbully.php <?php if (isset($id)) { $sql="SELECT * FROM table WHERE id='$id'"; $query=mysql_query($sql); $row=mysql_fetch_array($query); $name=$row[name];// this is the column name in your db for the name of the area $value=$row[value];// this is the column name in your db for value of incidents $newvalue=$value+1; $sql="UPDATE table SET value='$newvalue' WHERE id='$id'"; $query=mysql_query($sql); echo "$newvalue incidents in area $name"; } else { die("Error:$name not updated"); } Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777227 Share on other sites More sharing options...
patrickking04 Posted March 5, 2009 Author Share Posted March 5, 2009 processbully.php <?php if (isset($id)) { $sql="SELECT * FROM table WHERE id='$id'"; $query=mysql_query($sql); $row=mysql_fetch_array($query); $name=$row[name];// this is the column name in your db for the name of the area $value=$row[value];// this is the column name in your db for value of incidents $newvalue=$value+1; $sql="UPDATE table SET value='$newvalue' WHERE id='$id'"; $query=mysql_query($sql); echo "$newvalue incidents in area $name"; } else { die("Error:$name not updated"); } I Keep getting Error: not updated even tho its selecting the right database, table and it have the same named feilds. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777259 Share on other sites More sharing options...
kickstart Posted March 5, 2009 Share Posted March 5, 2009 Hi Suspect value on the table is a numeric field, so $value should not have quotes around it. All the best Keith Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777266 Share on other sites More sharing options...
patrickking04 Posted March 5, 2009 Author Share Posted March 5, 2009 hmmmm could it be my mysql database. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777317 Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 change die("Error:$name not updated"); to die("Error:$id not updated"); make sure that when you get the error it tells you the id you sent, also have you got an id column in your datasbase and is your database called table? Also the id column numbers would need to match the id numbers you send to the script. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777713 Share on other sites More sharing options...
kickstart Posted March 6, 2009 Share Posted March 6, 2009 Hi Try this <?php if (isset($id)) { $sql="SELECT * FROM `table` WHERE id=id"; $query=mysql_query($sql); $row=mysql_fetch_array($query); $name=$row[name];// this is the column name in your db for the name of the area $value=$row[value];// this is the column name in your db for value of incidents $newvalue=$value+1; $sql="UPDATE `table` SET value='$newvalue' WHERE id=$id"; $query=mysql_query($sql); echo "$newvalue incidents in area $name"; } else { die("Error:$id not updated"); } ?> Suspect table is a reserved word in mysql which could cause issues if you name a table that, hence surrounding it in apostrophies. Also not sure why you appear to have a $name field which isn't used. All the best Keith Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777754 Share on other sites More sharing options...
phpdragon Posted March 6, 2009 Share Posted March 6, 2009 The $name feild is used above in the echo statement as a visual reference for which area was updated, this way the user knows they have updated the right area. id's are for databases to reference, names are for people to reference. I wouldnt use the name table either as a tablename, I used that in my example so you could see I was referencing a table, you should call it something like schoolzones or zones or even areas its up to you. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777942 Share on other sites More sharing options...
patrickking04 Posted March 6, 2009 Author Share Posted March 6, 2009 Still a no go CREATE Table hotspot ( id int(11) NOT NULL, zone varchar(30) NOT NULL, bullcount varchar(1000) NOT NULL, KEY (ID) )"; <?php if (isset($id)) { $sql="SELECT * FROM `hotspot` WHERE id=$id"; //Select every thing from 'hotspot' table $query=mysql_query($sql); $row=mysql_fetch_array($query); $name=$row[zone];// Zone area $value=$row[bullcount];// counts of bullys $newvalue=$value+1; $sql="UPDATE `hotspot` SET value='$newvalue' WHERE id=$id"; //updates counts of bullys by +1 $query=mysql_query($sql); echo "$newvalue incidents in area $name"; //Prints new total count and area name. } else { die("Error:$id not updated"); //Prints error } ?> Just prints Error: not updated Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777975 Share on other sites More sharing options...
phpdragon Posted March 6, 2009 Share Posted March 6, 2009 needs to be id=$id in your SELECT statement and you have called the counter bullcount so it should be $sql="UPDATE `hotspot` SET bullcount='$newvalue' WHERE id=$id"; Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777976 Share on other sites More sharing options...
patrickking04 Posted March 6, 2009 Author Share Posted March 6, 2009 nope Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777978 Share on other sites More sharing options...
phpdragon Posted March 6, 2009 Share Posted March 6, 2009 and you have called the counter bullcount so it should be $sql="UPDATE `hotspot` SET bullcount='$newvalue' WHERE id=$id"; Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777979 Share on other sites More sharing options...
patrickking04 Posted March 6, 2009 Author Share Posted March 6, 2009 make the change to the code. but still no. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777981 Share on other sites More sharing options...
patrickking04 Posted March 6, 2009 Author Share Posted March 6, 2009 does there need to be a ! in the isset? like so if (!isset($id)) Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777984 Share on other sites More sharing options...
phpdragon Posted March 6, 2009 Share Posted March 6, 2009 If you put the ! in it means if it is not set, you want it to be set, you did also how ever miss the ' in your following lines $name=$row['zone'];// Zone area $value=$row['bullcount'];// counts of bullys Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-777996 Share on other sites More sharing options...
patrickking04 Posted March 6, 2009 Author Share Posted March 6, 2009 nope not understand, no error are coming up. <?php if (isset($id)) { $sql="SELECT * FROM 'hotspot' WHERE id=$id"; //Select every thing from 'hotspot' table $query=mysql_query($sql); $row=mysql_fetch_array($query); $name=$row['zone'];// Zone area $value=$row['bullcount'];// counts of bullys $newvalue=$value+1; $sql="UPDATE 'hotspot' SET bullcount='$newvalue' WHERE id=$id"; //updates counts of bullys by +1 $query=mysql_query($sql); echo "$newvalue incidents in area $name"; //Prints new total count and area name. } else { die("Error:$id not updated"); //Prints error } ?> Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-778006 Share on other sites More sharing options...
phpdragon Posted March 6, 2009 Share Posted March 6, 2009 do you have data in your database? do the id numbers in the database match the id numbers you are sending from your hotspot? also the bullcount feild in your database is not right, the number you set in the the brackets there, 1000 is way to big, that means it can be 1000 characters not the number 1000, you should set as int(10) for that column, which means an integer upto 10 characters long which would mean you can count upto 999999999 which i dont beleive you will ever reach. Also take the ' away from the table name, this should only be hotspot not 'hotspot' in both of your sql queries, as $id in your queries is a variable I would also make it '$id" to prevent SQL injection attacks. also you set key as ID when in fact it is id, check your variable for case sensitivity also just above the if (isset($id)), add this echo "ID is ($id)."; if you dont get a number at the top of your page between the brackets, then you are not sending the variable id right Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-778020 Share on other sites More sharing options...
patrickking04 Posted March 6, 2009 Author Share Posted March 6, 2009 yeah your right it not sending it across. ID is ().Error: not updated im using the processbully.php?id=1 thing you help me with at the beginning. Link to comment https://forums.phpfreaks.com/topic/148068-solved-map-hotspot/#findComment-778025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.