Jump to content

Set variables from buttons. how would i code something like this...?


Alexhoward

Recommended Posts

Hi guys,

 

firstly thanks for all the help i've recieved through this site,

 

it's been invaluable to creating my site.

 

Now it's finished however, i'd like to redisign...

 

my question is this:

 

At the moment i've got lots of pages with slighlty different code to pull data out of a table differently.

 

What i'd like to do, is change the variable dynamically, so i can achieve the same results with less pages.

 

so,

 

say the bones of the code to pull the data was something like...

 

SELECT * FROM 'table' $cat $subcat $sort

 

I'd like to be able to select a category from a DHTML tree, and it will set the variables for that category

 

e.g. - Mens Clothing

 

so it would make to select code:

 

SELECT * FROM 'table' WHERE cat ='fashion' and subcat ='mens'

 

then you could press the sort by name (for example)

 

and it would make it:

 

SELECT * FROM 'table' WHERE cat ='fashion' and subcat ='mens' sort by 'company_name'

 

I imagine i'd have to make everything a form, and have a giant list of IF's to make this work, but i'm still a semi noob and don't really know how to start.

 

Thanks for your time and help in advance

 

Alex Howard

Link to comment
Share on other sites

If you're every considering a huge number of if statements, then dont. There's almost certainly a better way.

 

What i would suggest is that you set up a couple of database tables:

 

categories: id, name

sub_categories: id, cat_id(the id of the categories this is a sub-category of), name

 

You'll then want to pass the category id and sub-category id around in the URL. When your page loads, you'll grab these pieces of information and work out what is being displayed. You'll also display the relevant items. You can then add searching and sorting from there.

Link to comment
Share on other sites

Hi,

 

thanks for your reply.

 

I can't start making other tables now,

 

it took long enough to input all the data in to the one i've got.

 

this has the columns

 

company_name | cat | subcat | link | keywords

 

and is already a few hundred rows long.

 

searching works fine through the keywords column

 

i assumed it would work like a sort button?

Link to comment
Share on other sites

Ok,

 

so it's better to have lots of little tables.

 

and join them all together.

 

Surley the only problem is that if you were editing them manually, you'd have no idea what you where looking at with just int primary keys...?

 

bubt i understand.

 

this would however need a full re-build :-\

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.