472,808 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,808 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 1357
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
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.