View Full Version : What Do I need To Do To Get This To Work Please?
Byronwells
01-29-2010, 04:15 PM
Alright Guys
I have created this field (licence) within a database. I then have gone ahead a created a drop down menu and given it the name licence,
<select size="1" name="licence" value="{{licence}}">
<option value=0>Select</option>
<option>Basic Resale Rights</option>
<option>Master Resale Rights</option>
<option>Personal Use Only</option>
<option>Private Label Rights</option>
</select></td>
I then wrote some php code to the database and above drop down menu to work together
$licence = $_POST["licence"];
I know that all of the above work so far because I have got it the information to appear on this page
http://www.digitalresellersvault.com/marketplace.php?cat=t&category=Private_Label_Rights
My question is what if I wanted to be able to select two licences. Would I need to create another field and call it licence2 and then it displayed like how I have done above??
angst
01-29-2010, 04:45 PM
this isn't really an sql question, but you can do it by adding this:
<select size="1" name="licence" MULTIPLE SIZE=5>
more info: http://www.htmlcodetutorial.com/forms/_SELECT_MULTIPLE.html
also, you can't use "value" in the <select> tag. value is only used in the <option> tags.
I think it is a MySQL quetion.
What you are discussing seems to be the possibility that a person may have more than one licence.
In that case your db will need to have a new table -> user_licences to support that 1->many relationship. It would store data like this
user | licence No. |
01 | 234|
01 | 543|
02 | 234|
03 | 234|
03 | 543|
Then in your html form, you'll need to offer checkboxes, rather than a select, so they can select more than one licence.
I suppose you could allow for more functionality...what if they want two licences but, of the range open to them, some are mutually exclsive? say, you can have licence 1 or 2 and 3 or 4. then you could put 1&2 into a section with radio buttons and 3&4 into another form section, with radio buttons. That way; they are allowed to choose 1 or 2 as well as 3 or 4. depends how much you need to provide, to make sure they don't select stuff they shouldn't / can't.
I hope that makes sense but, if not, post back.
bazz
Old Pedant
01-29-2010, 07:43 PM
Agree with Bazz excepting only that you *can* use SELECT MULTIPLE.
I think that with a PHP server you will need to use [] on the name, thus:
<select name="licence[]" multiple size="5">
And then treat it the same way you would treat a set of same named checkboxes.
You can see what I mean using this HTML page:
<html>
<body>
<form>
<input type="checkbox" name="CB" value="1">
<input type="checkbox" name="CB" value="2">
<input type="checkbox" name="CB" value="3">
<input type="checkbox" name="CB" value="4">
<input type="checkbox" name="CB" value="5">
<br/>
<select name="SEL" multiple size="5">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<br/>
<input type="submit">
</form>
</body>
</html>
Check 2 or 3 checkboxes and select 2 or 3 options and hit the submit button.
Look at the address line of your browser. You will see something like:
http://localhost/test/junk5.html?CB=2&CB=4&SEL=1&SEL=3
See? The browser sends the same thing to the server for a set of same-named checkboxes as it does for <select multiple>. So you can and should treat them the same. In JSP and ASP, you could just code them as shown. For PHP, you need the funky [] on then ends of the names.
Byronwells
01-29-2010, 08:14 PM
Agree with Bazz excepting only that you *can* use SELECT MULTIPLE.
I think that with a PHP server you will need to use [] on the name, thus:
<select name="licence[]" multiple size="5">
And then treat it the same way you would treat a set of same named checkboxes.
You can see what I mean using this HTML page:
<html>
<body>
<form>
<input type="checkbox" name="CB" value="1">
<input type="checkbox" name="CB" value="2">
<input type="checkbox" name="CB" value="3">
<input type="checkbox" name="CB" value="4">
<input type="checkbox" name="CB" value="5">
<br/>
<select name="SEL" multiple size="5">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<br/>
<input type="submit">
</form>
</body>
</html>
Check 2 or 3 checkboxes and select 2 or 3 options and hit the submit button.
Look at the address line of your browser. You will see something like:
http://localhost/test/junk5.html?CB=2&CB=4&SEL=1&SEL=3
See? The browser sends the same thing to the server for a set of same-named checkboxes as it does for <select multiple>. So you can and should treat them the same. In JSP and ASP, you could just code them as shown. For PHP, you need the funky [] on then ends of the names.
hmmm
I just thought of something else..
On my script I would like to be able to choose a selection of categories.. I will at a later stage devise sub categories, and main categories..
I know that there is a field in the smp_products for categories.. And then their is a sepearate table for categories as well..
To get that to work would I have to create a brand new table... etc??
Agree with Bazz excepting only that you *can* use SELECT MULTIPLE.
I just something new :thumbsup: :)
bazz
Old Pedant
01-30-2010, 01:16 AM
Same question as in the other thread.
Yes, anytime you have two tables that are multiply related (that is, in your case, one product can appear in multiple categories and one category can appear in multiple products), you need a many-to-many table. Period.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.