jerryco Posted February 27, 2012 Share Posted February 27, 2012 Hi im new to the forum and am after a solution to my problem and how to go about it? I am in the process of building a site in php but am requiring a speedo type dial image which would possibly change on the out come of a database query if this make sense.. Basically the site user would submit a form which in turn would write name, region a £ amount to the mysql database table, this in turn would tot up with all the other entries of the day and display the cost savings on the said speedo type gauge, then a news type ticker to display ('name' from 'region' saved'£xxx') which would scroll with the say last ten entries and then if possible an extra text box to display 'totals saved to date' which would add all the submissions to date. Hope this is possible and someone could spread some light on ho to go about doing it. Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/ Share on other sites More sharing options...
requinix Posted February 27, 2012 Share Posted February 27, 2012 speedo type dial image That puts all kind of weird images in my head... The database design sounds quite simple. You'll want two tables: one for regions and one for these savings. The regions table is so that you don't have to try to parse or format or recognize names that people enter - they just pick one from a list. The table provides that list. The savings table has columns for a date, the user's name, a foreign key to the regions table (to identify the region), and an amount in pounds. Querying those tables is also very easy and can provide everything you've mentioned. But what's a "speedo type dial image" and a "speedo type gauge"? Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321756 Share on other sites More sharing options...
jerryco Posted February 27, 2012 Author Share Posted February 27, 2012 Thanks for the quick reply.. and sorry for not being clear. The image would be a graphic of a car speedometer and the needle would rise and fall depending on the value saved on the given day. The totals saved would be the mileometer within this.. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321764 Share on other sites More sharing options...
ManiacDan Posted February 27, 2012 Share Posted February 27, 2012 So you want PHP to dynamically draw a speedometer and odometer based on two different database values? That's significantly harder, look into the GDImage extension. Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321767 Share on other sites More sharing options...
Zane Posted February 27, 2012 Share Posted February 27, 2012 when I google "create php odometer", I get this http://jpgraph.net/download/manuals/chunkhtml/ch20s02.html Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321770 Share on other sites More sharing options...
jerryco Posted February 27, 2012 Author Share Posted February 27, 2012 Thanks for the replies well my thoughts were that i could save say six images of the speedometer with the needle indicator in a different place then depending on the database value it could somehow display one of the images? obviously it ould be magic if i could incorporate say jquery for a smooth rising needle on the gauge but this not essential. Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321771 Share on other sites More sharing options...
requinix Posted February 27, 2012 Share Posted February 27, 2012 For a static image the basic strategy is to draw the needle on top of a background image. Depending on the needle the drawing can be easy or difficult. For a rising needle, look to canvas/SVG first using the same basic "drawing a needle on top" idea. Those can handle it quite easily and should cover most browsers. It would also mean you could, say, fire off occasional AJAX queries to see how the figure has changed since it was first loaded and move the needle accordingly. On a different note: IMO a speedometer doesn't quite have the same connotations of saving money: one is about going faster while the other is about spending slower. It's the same way a thermometer wouldn't be appropriate: rising temperatures versus falling costs (not to mention that thermometers are most often used in fundraising-type situations). If you'd like more ideas could you describe what these people are saving money on? Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321775 Share on other sites More sharing options...
Philip Posted February 27, 2012 Share Posted February 27, 2012 I'd suggest just going the jQuery route and using a plugin that does this already - especially if you're wanting fancy animations and what not. Here is one but be warned, raphael.js doesn't work on mobile, but it is one of the few that works on IE7 & 8. Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321776 Share on other sites More sharing options...
jerryco Posted February 27, 2012 Author Share Posted February 27, 2012 Ok cool so i could fire up illustrator for a svg and use this? i can do the layers etc and create the image/s but hat i would struggle with is putting it all together to make it function as intended.. this is the area i fall down again thanks for any help.. Quote Link to comment https://forums.phpfreaks.com/topic/257882-linking-an-image-to-a-database-query/#findComment-1321778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.