Display Filtered Data with Dynamic Titles

03-21-09, 09:02 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2009
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Display Filtered Data with Dynamic Titles
Here is what i am trying to accomplish. I have written a program for voting. The table that i am pulling the data from is called join and it has (ID, event_name, position, and candidate_name)
example
id = auto#
event_name = Elections
position = President, Vice, etc...
candidate_name = john, jill, tom, etc...
I want to give the user the option to create different positions so that filed is dynamic (done)
I have created the entire program, but now am stuck on the actual page that people would vote on. I need to create a page that will show each position (president, vice, etc..) and all the candidates that are running for that position in a drop down menu.
example
president
drop down menu - tom, bill, sally
vice president
drop down menu - jill, bob, mike
$any_value_the_user_enters
drop dwon menu - todd, colin, cheryl
i would post the current code that i have already created, but i think i am going in the wrong direction with it. This is only my second php program that i have written so i am still kind of new at this.
Thanks,
Ben
|

03-21-09, 09:24 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
Step 1: Assuming your using MySQL, you will need to rename your table, as "join" is a keyword.
Step 2: I'm a little confused as to what you want. You want self populating drop down (<select>) boxes? And, you want those boxes grouped under Positions?
|

03-21-09, 09:34 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2009
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am using MySQL ??? confused as to rename table as keyword
I am trying to make it so the code will look at the column 'position' and find all of the different types of positions. (President, Vice President, Treasurer, what ever is in that column.)
Then i want to make a page that will say the position, and every one who has the position listed in that table.
data example
id elections position candidate
1 officer president ben
2 officer president cheryl
3 officer vice mike
4 officer vice tom
now i want them to see
president
drop down box displaying ben and cheryl
vice
drop down box displaying mike and tom
I dont know all of the positions ahead of time as i dont all of the posionts for the end user so i need to have the script find the all of the different positions that are listed in the field.
Last edited by software4; 03-21-09 at 09:37 PM.
|

03-21-09, 09:41 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
I am stating that MySQL see's the word "JOIN" as an operator, and will reject all queries and throw an error.
So you will need to rename your table to something different.
Give me a minute, I'll see what I can work up for you...
|

03-21-09, 09:42 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2009
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is what i have come up with, but it does not give me the flexibility for variables that i dont know in the position field
and here is what I have in my form
|

03-21-09, 10:35 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
See if this helps you out any. I set up a temp table on my local DB named "test"
So append that section in the Query to your table name, I used the column's you specified.
|

03-21-09, 11:06 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2009
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
First off, i must say, you ROCK... That worked perfect. I need to remove the table, but other then that, it is exactly what I was looking for. That was way above my php level and would have taken me ages to figure out. I am now realizing that I will have some more hurdles to overcome such as now how to store that in a database. I don’t think what I have setup will work.
I appreciate your help and was wondering if I could pay you a little for some more consulting as I would not want to take advantage of your kindness. Of course if you just get a high from helping struggling php writers that is great as well.
|

03-21-09, 11:11 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
I really don't mind helping at all, and I could never accept money for it.
That being said,
I'll be right back with a db script for you... (since your so nice  )
|

03-21-09, 11:13 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2009
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
here is a view on what i am doing
http://software4schools.com/vote/admin_login.php
you can log in with admin / admin
its all test data, so mess around...
|

03-21-09, 11:20 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2009
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is what I still need to accomplish…
I have it setup so their can be multiple events running at the same time. Each event has a start and stop date so end users can only vote during that time per each event
I also need to validate that an end user can only vote once for each event.
I still need to post this data to the database table ‘votes’ What I am perplexed about is how to post this in a database where it will show that a single user voted for multiple officers(positions) in one single post.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|