wadet Posted October 4, 2010 Share Posted October 4, 2010 I am looking for some advice on how I would go about creating a script does checks stock from popular online retailers, and also pulls in the price and then arranges them from cheapest to most expensive, you probably will know what I mean, There are plenty websites online already that do this, but something I want to achieve is on a smaller scale and just for one product, reason being is that its for a university project of mine and I just need something smaller to focus on, the basics of such a script really. I am learning PHP from the ground up, so keeping it simple is best. Sites like http://www.wii-consoles.co.uk/ and http://www.cheapest-in-stock.com/ I have seen various scripts I could by online, however as this is for a project, I need to create it myself from the ground up, though working from an example would be good, I'm wondering if anyone here could give me a few tips as to what such a script requires, and what I am likely to have to learn. I look forwards to your replies! Thx wadet Link to comment https://forums.phpfreaks.com/topic/215127-php-stock-checker-price-comparison/ Share on other sites More sharing options...
GuardianGI Posted October 4, 2010 Share Posted October 4, 2010 how are you going to collect the prices (where are u going to get them from?) if u get them manually and make a database table form them u can simply get them using mysql_query('SELECT * FROM `products` SORT BY `price`;'); something in that direction. if u deice to get them 'on the fly' I'd insert them all into an array and then use php's built in asort($array); you'd get something like this (i have 3 test values in the array since i have no idea how u plan on getting them.) $array = array('productA'=>12, 'productB'=>17, 'productC'=>11.5 ); asort($array); echo 'least expensive to most expensive:<br />'; foreach($array as $key=>$val) { echo $key.' at $'.$val.'<br />'; } /*would output (after being parsed by a browser) least expensive to most expensive: productC at $11.5 productA at $12 productB at $17 */ you would just have to make something to insert your product names (or location or w/e) into he key field and the value into the value of the arrays EDIT: changed sort to asort, since a sort doesn't leave the keys in tact! Link to comment https://forums.phpfreaks.com/topic/215127-php-stock-checker-price-comparison/#findComment-1118887 Share on other sites More sharing options...
wadet Posted October 4, 2010 Author Share Posted October 4, 2010 Hey! Cheers for the reply! Well, I am not entirely sure how I would get any data to be honest, the prices and whichever other data would come from the retailers websites... Far as I know, regarding the stock part is the script perhaps looks for the common words a retailer would use to describe or show thier product was in stock, so the script can pick that out. Far as anytihng else I really just need suggestions as to how this script would go together to do what I need it to do, I dont have any php knowledge so pretty much dont have a clue. I have been doing research trying to find similiar scripts available online so that I can study them. I would then understand them once I have learnt some php ( I am currently working through a beginners PHP book) Cheers! Link to comment https://forums.phpfreaks.com/topic/215127-php-stock-checker-price-comparison/#findComment-1119063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.