|
|
Subject:
simple image based CGI Script needed for stock control
Category: Computers > Programming Asked by: bvandyk-ga List Price: $25.00 |
Posted:
12 Jul 2006 04:10 PDT
Expires: 11 Aug 2006 04:10 PDT Question ID: 745546 |
I need a very simple CGI script written that will act as a simple stock management system for a website I run. It will be used multiple times per webpage, with the following syntax: <img src="cgi-bin/stock.cgi?model=nk6210"> Defined within the CGI script will be the following list of phone models: nk3210 = 0 <meaning that the phone is OUT of stock> nk6210 = 1 <meaning that the phone is IN stock> ... If the requested item is in stock the "image 1" will be displayed, if the item is out of stock then "image 2" will be returned, if the requested phone was not found in the list then "image 3" will be returned. I can insert the binary for the images later if a marker is put in the code for this. The code should be very fast and efficient as the script maybe called 30 times on one html page. Please ask me if any clarification is needed. | |
| |
| |
|
|
There is no answer at this time. |
|
Subject:
Re: simple image based CGI Script needed for stock control
From: bozo99-ga on 12 Jul 2006 16:14 PDT |
Defined within the CGI script ... Surely stock levels are better defined in some readily changeable form of data and the CGI will remain unchanged for the long term. |
Subject:
Re: simple image based CGI Script needed for stock control
From: bozo99-ga on 13 Jul 2006 02:10 PDT |
#!/usr/bin/perl print "Content-Type: image/png\n\n"; $got="unknown"; if (defined($ENV{QUERY_STRING})) { if ($ENV{QUERY_STRING} =~ /^model=(\w+)$/) { $sku=$1; } } $got="yes" if ("nk6210" eq $sku); $got="no" if ("nk6211" eq $sku); if ("yes" eq $got) { open(IN, "</SOME-PATHNAME/hand.up.png") or die(); undef $/; $_=<IN>; close(IN); printf("%s", $_); exit(0); } if ("no" eq $got) { open(IN, "</SOME-PATHNAME/broken.png") or die(); undef $/; $_=<IN>; close(IN); printf("%s", $_); exit(0); } open(IN, "</SOME-PATHNAME/bomb.png") or die(); undef $/; $_=<IN>; close(IN); printf("%s", $_); exit(0); |
Subject:
Re: simple image based CGI Script needed for stock control
From: bozo99-ga on 13 Jul 2006 02:11 PDT |
Would it be better to use the GCI to write the page containing these links? This should reduce the number of CGI executions. |
Subject:
Re: simple image based CGI Script needed for stock control
From: bozo99-ga on 13 Jul 2006 02:19 PDT |
In fact with multiple links on the page and only 3 outcomes you'll end up serving the same image repeatedly instaed of using the cache. I definitely side with writing the HTML page dynamically intead of the images. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |