473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Whats the best way to do this?

Hi, I currently have a website that uses an option drop down box to
select different colours for an item before the form it is in is
submitted.

This works fine but as I am trying to advance my skills I decided to
learn PHP to use with SQL which I already know. I have yet to start but
am thinking of how to go about it and looking at some example code. The
whole thing looks easier enough but I was wondering how these option
boxs would fit into it.

I'm thinking one way to possibly do it would be an array with all the
options in. However, would it be possible to have what should be the
contents of the array as part of the table? For eg something like:

Colours
-----------
Blue,black,green

And also would it be possible using these to change the price of an
item? That isn't so important now but may be useful in the future,
although I can make it work another way if need be.

Any help much appreciated!

Thanks

Flic

Sep 11 '06 #1
3 1395
PHP is a server side language so you would use it to replace hard coded
<OPTION value = Blue>Blue</OPTION>
<OPTION value = Green>Green</OPTION>
<OPTION value = Black>Black</OPTION>

with colours from a database query or some other source. The HTML page
you generate doesn't care if it was hard coded or built on the fly by
PSP / ASP or anything else.

As for changing the prices would be to either embed the price in the
code somewhere
<OPTION value = Blue(14.99)>Blue</OPTIONor as a hidden field on the
form, containing an array of the data you need...

and use javascript to change a form field value client side, or to
resubmit the page and find the correct price for the item added.
Personally I'd resubmit coz lots of people have JS turned off and
otherwise they would be able to see the data in its raw form.

Aaron

Flic wrote:
Hi, I currently have a website that uses an option drop down box to
select different colours for an item before the form it is in is
submitted.

This works fine but as I am trying to advance my skills I decided to
learn PHP to use with SQL which I already know. I have yet to start but
am thinking of how to go about it and looking at some example code. The
whole thing looks easier enough but I was wondering how these option
boxs would fit into it.

I'm thinking one way to possibly do it would be an array with all the
options in. However, would it be possible to have what should be the
contents of the array as part of the table? For eg something like:

Colours
-----------
Blue,black,green

And also would it be possible using these to change the price of an
item? That isn't so important now but may be useful in the future,
although I can make it work another way if need be.

Any help much appreciated!

Thanks

Flic
Sep 11 '06 #2

frothpoker wrote:
PHP is a server side language so you would use it to replace hard coded
<OPTION value = Blue>Blue</OPTION>
<OPTION value = Green>Green</OPTION>
<OPTION value = Black>Black</OPTION>

with colours from a database query or some other source.
I know this much, my question was how? If each of the different item
had different colours how would it be best to populate the list?
Something like i++ would work on single rows, but what about a single
entry?

Sep 11 '06 #3
Flic wrote:
frothpoker wrote:
>PHP is a server side language so you would use it to replace hard coded
<OPTION value = Blue>Blue</OPTION>
<OPTION value = Green>Green</OPTION>
<OPTION value = Black>Black</OPTION>

with colours from a database query or some other source.

I know this much, my question was how? If each of the different item
had different colours how would it be best to populate the list?
Something like i++ would work on single rows, but what about a single
entry?
If you do not mind you could use the PEAR package HTML_QuickForm. With
this package I can load a dropdown, from a database table, in three
statements. Example:

//
// Add the <Selectload from $DB to form
$s =& $form->createElement('select','u_category','Category:' );
$s->loadQuery($db, $category_dropdown_select);
$form->addElement($s);

There is a excellent tutorial on using the HTML_QuickForm package here:

http://www.devarticles.com/c/a/Web-G...orm-Processing

I have not look at HTML_QuickForm2 that is suppose to be a newer
incarnation of HTML_QuickForm.

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Sep 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eva | last post by:
Hi all, I just wanted some advise on what control is best to use in my situaton. What i am trying to achieve is to allow the user to enter 1 or more room names into a control of some sort so...
3
by: Kevin Steffer | last post by:
Hi group I have a webform which I want to make an ftp connection for a filetransfer from. The thing is when I use the WebRequest class it says "The URI prefix is not recognized" and my URI is...
2
by: SOR | last post by:
I'm writing a guestbook and given the number of entrys the guestbook might have can vary quite a lot - the nav links to view the guestbook entrys need to generated live at the time to suit . ...
5
by: Panama Red | last post by:
I would like to learn to program in c++ on Linux and AIX systems...mainly socket and fifo type stuff. Can someone recommend a book for someone with experience only with Perl, shell, and Pick/Basic...
4
by: David Lozzi | last post by:
OK simple question. Whats the default value for an string() array? sub LoadStuff(byval one as integer, byval two as string, optional byval three() as string = ??) Its driving me nuts! ...
4
by: markrush | last post by:
if i have 2 datasources with different table names and column headers that i want to merge i.e. "ptitle" and "name" whats the best way of doing this? are there any standard routines or should i use...
16
by: Brian Henry | last post by:
Is there a listing out there anywhere that lists what is new in .NET 2.0 mainly in VB? I've seen simple lists like oh we have all these new controls, but I want a class list and such also. thanks!
2
by: moondaddy | last post by:
I'm using WPF and c#. Whats the best way for a child class to know about it's parent class? For examle class ParentClass : CollectionBase { // code... class ChildClass { // code...
4
by: LoneHunter01 | last post by:
Basically, I just need a general direction on where to go for this. Yes, this is for a school project, though it's strictly an optional one (and I have tried many solutions, one in-depth). We've...
7
by: Paulo | last post by:
Hi, what is diference between: File -New Web Site and File -New Project -VB/C# -Web Application ?????? VS 2005
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.