Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,500 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,733 people online right now. Registration is fast and FREE... Join Now!




whats the best way to do this

 
Reply to this topicStart new topic

whats the best way to do this

capty99
29 Feb, 2008 - 10:14 PM
Post #1

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,164



Thanked: 16 times
Dream Kudos: 550
My Contributions
again, thanks to everyone who has been helping me out the last week... my re-adventures into php have so far caused problems but i've fixed them with yall's help.

one more coming up later tonight unless i can figure it out before then , but for now , just a theory from yall would be great.

i have a db table 'stores'

with a bunch of info one of the columns being 'type.'

types would be like.... youth-clothing , adult-clothing, shoes for example

i want to build out the navigation of my site... and just do it depending on whats actually in the db... so for the navigation by category

i want to list the youth-clothing and then as sublinks .... all the stores that fit in that category.


how do i go through my db and pull out all the type names, and then print them to the nav without duplicates....

and then after that for the subcategories i can easily enough just print all the store names WHERE the type matches, so i have that under control.

just that first part of pulling out the types and making sure i only have a single, and not like 12 'shoes'

does that make sense?
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Whats The Best Way To Do This
29 Feb, 2008 - 10:28 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,993



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
I imagine, since you're working in PHP, that your database is mySQL. What I would do is use the DISTINCT keyword, this will then only retrieve distinct values, thus no duplicates


php

$query = "SELECT DISTINCT types FROM YourTable";


This post has been edited by PsychoCoder: 29 Feb, 2008 - 11:06 PM
User is offlineProfile CardPM
+Quote Post

capty99
RE: Whats The Best Way To Do This
29 Feb, 2008 - 11:00 PM
Post #3

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,164



Thanked: 16 times
Dream Kudos: 550
My Contributions
who would have thought such a thing existed

thats why i keep you around.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Whats The Best Way To Do This
29 Feb, 2008 - 11:15 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,993



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
No problem Tyler, glad I had an answer for you
User is offlineProfile CardPM
+Quote Post

capty99
RE: Whats The Best Way To Do This
1 Mar, 2008 - 01:12 AM
Post #5

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,164



Thanked: 16 times
Dream Kudos: 550
My Contributions
another question for ya:

when i set up just the real simple cms i know how to do.
i build a main page that lists the current ... lets say news updates ....

and then under each title is an edit | delete buttons...
and at the top an add new update button.

the delete is easy enough.
whats annoying is when these pages start having a bunch of different form fields in them... and they have to be duplicated for both the add and edit pages.

i mean, its nothing tough, but is it common to do it like i am, or on a larger scale are the forms set up depending on the tables in the db.
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: Whats The Best Way To Do This
1 Mar, 2008 - 07:05 AM
Post #6

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

i have done this a few times..some was very detialed and elborate, with types of alloud data, int , strings, default values.

make a function.
i usually make array's of feild names for the type field, input text, raidio and textarea...etc.

then, fetch assoc,
foreach row as idx = > val.
if(in_array(val,text_array))
echo imput stuffs
elseifin_array(val,textarea_array))
echo textarea's

hmm, i have a quick and dirty one on my site you can use as an example.
the email mysql one.
builds the DB based on array of field names, checks required.
other stuff i not remember atm.

User is offlineProfile CardPM
+Quote Post

capty99
RE: Whats The Best Way To Do This
1 Mar, 2008 - 02:17 PM
Post #7

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,164



Thanked: 16 times
Dream Kudos: 550
My Contributions
thx spaceman, i might try doing that if this project grows very much.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 08:08PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month