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!
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'
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
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.
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.