Home > Archive > PHP SQL > March 2005 > Multiple Categories
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Multiple Categories
|
|
| Jeremy Ross 2005-03-16, 3:58 pm |
| Hello,
I am looking for a tutorial, or some help with a slight problem that I am
having.
What I need to do is create a bit of code that will allow me to select
multiple categories for a product. I all ready have it so I can pick form a
list of categories and unlimited sub categories. Now I need it so I can
select mutable categories from a list, and the product gets displayed on
them all.
I am using MySQL and PHP for this.
Thanks for any help
Jeremy Ross
| |
| Tex John 2005-03-16, 8:56 pm |
| You mean like this?
http://www.onlinetools.org/tricks/u...iple_select.php
(use the CTRL key obviously...)
John
in Houston
"Jeremy Ross" <reply@newsgroup-please.com> wrote in message
news:qwXZd.60323$fc4.16306@edtnps89...
> Hello,
>
> I am looking for a tutorial, or some help with a slight problem that I am
> having.
>
> What I need to do is create a bit of code that will allow me to select
> multiple categories for a product. I all ready have it so I can pick form
a
> list of categories and unlimited sub categories. Now I need it so I can
> select mutable categories from a list, and the product gets displayed on
> them all.
>
> I am using MySQL and PHP for this.
>
> Thanks for any help
> Jeremy Ross
>
>
| |
| Jeremy Ross 2005-03-17, 3:57 pm |
| Hello,
I know that using the CRLT key will select multable things on a list, and
return them in an array. The major question I have is how can I store that
array in a database, that would be an useful format for me to use a select
query in MySQL
Thanks,
Jeremy Ross
"Tex John" <john@logontexas.com> wrote in message
news:p90_d.5951$Ux.3336@tornado.texas.rr.com...
> You mean like this?
>
> http://www.onlinetools.org/tricks/u...iple_select.php
>
> (use the CTRL key obviously...)
>
> John
> in Houston
>
> "Jeremy Ross" <reply@newsgroup-please.com> wrote in message
> news:qwXZd.60323$fc4.16306@edtnps89...
> a
>
>
| |
| Soulman 2005-03-17, 3:57 pm |
| "Jeremy Ross" <reply@newsgroup-please.com> wrote in message
news:iNf_d.59765$i6.30427@edtnps90...
> Hello,
>
> I know that using the CRLT key will select multable things on a list, and
> return them in an array. The major question I have is how can I store
> that array in a database, that would be an useful format for me to use a
> select query in MySQL
>
Try the SET datatype (MySQL native)
http://dev.mysql.com/tech-resources...t-datatype.html
but also read the "why you shouldn't use set" thing.
--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com
| |
| Tex John 2005-03-18, 3:57 pm |
|
<select name="test[]" multiple="multiple">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
<option value="five">five</option>
</select>
$query = "INSERT INTO database SET ";
for ($x = 0; $x < count($test); $x++) {
$query .= "column = '".$test[$x]."'";
if($x < (count($test) + 1)) $query .= ", ";
}
$query .= "WHERE foo = 'bar'";
You mean like that?
John
"Jeremy Ross" <reply@newsgroup-please.com> wrote in message
news:iNf_d.59765$i6.30427@edtnps90...
> Hello,
>
> I know that using the CRLT key will select multable things on a list, and
> return them in an array. The major question I have is how can I store
that
> array in a database, that would be an useful format for me to use a select
> query in MySQL
>
> Thanks,
> Jeremy Ross
>
>
> "Tex John" <john@logontexas.com> wrote in message
> news:p90_d.5951$Ux.3336@tornado.texas.rr.com...
am[color=darkred]
can[color=darkred]
on[color=darkred]
>
>
| |
| David Robinson 2005-03-19, 8:56 am |
| "Tex John" <john@logontexas.com> wrote in message
news:qaF_d.2230$ot.1745@tornado.texas.rr.com...
>
> <select name="test[]" multiple="multiple">
> <option value="one">one</option>
> <option value="two">two</option>
> <option value="three">three</option>
> <option value="four">four</option>
> <option value="five">five</option>
> </select>
>
>
> $query = "INSERT INTO database SET ";
> for ($x = 0; $x < count($test); $x++) {
> $query .= "column = '".$test[$x]."'";
> if($x < (count($test) + 1)) $query .= ", ";
> }
> $query .= "WHERE foo = 'bar'";
>
> You mean like that?
>
> John
>
Don't forget to add a space between columns:
.....
$query .= "column = '".$test[$x]." '";
....
| |
| R.Lange 2005-03-19, 8:56 pm |
| David Robinson wrote:
> "Tex John" <john@logontexas.com> wrote in message
> news:qaF_d.2230$ot.1745@tornado.texas.rr.com...
>
>
>
> Don't forget to add a space between columns:
>
> ....
> $query .= "column = '".$test[$x]." '";
> ...
This will put a space at the end of the string being inserted into the
database. I doubt that's the desired effect. From his setup, I'd say the
space would be better off in front of the WHERE keyword, like so:
$query .= " WHERE foo = 'bar'";
| |
| David Robinson 2005-03-19, 8:56 pm |
| "R.Lange" <cl1mh4224rd@gmail.com> wrote in message
news:E_ydnWTOuZg9EqHfRVn-iQ@comcast.com...
> David Robinson wrote:
>
> This will put a space at the end of the string being inserted into the
> database. I doubt that's the desired effect. From his setup, I'd say the
> space would be better off in front of the WHERE keyword, like so:
>
> $query .= " WHERE foo = 'bar'";
You're quite right, my space was in the wrong place. What I was getting at
is that the query would output columns like this:
.... column_a = 'foo'column_b='bar' ...
The space should appear after each column, since the for() suggests the
possible use of multiple update fields:
$query .= "column = '".$test[$x]."' ";
|
|
|
|
|