PDA

View Full Version : Help With Dropdown in Template/PHP


aggiefan
07-01-2006, 07:41 PM
I'm working on a 3.5 modification (first time ever) of a sports "pick 'em" contest that is similar to vBPool. I had created it for 3.0, but the upgrade to 3.5 killed it. Football season is coming up and I'm trying hard to get it up and running again for this year. My problem is as follows:

I need the dropdown box (setup in the template) to go read a table in my database called vBContests and display all the results it finds (loop until fails). vBContests is one column (column name is contestname). I then just want them to select the result that they want. It doesn't have to do anything when they select it other than display it in the box.

My question, and I'm no coder, so forgive me if it's dumb...but can somebody help me with the javascript text in the template and the related php code for the php file (the query)?

I've tried to look at other hacks and can't find anything similar. The quick style chooser may be doing what I want -- but I haven't been able to figure out how that works. If anybody can help, I'd be greatly appreciative.

UPDATE

Okay, I've got it semi-working...but it's just displaying the first table and not looping to all of them. I know my code is wrong -- since it's bits and pieces from different places...so, can somebody offer advice?

My PHP code:
$activecontestquery = $db->query_read("
SELECT *
FROM vBContests

");

if (!$db->num_rows($activecontestquery))
{
$contesterr = '<div align="center"><em>There are no contests!</em></div>';
}
else
{while ($contest = $db->fetch_array($activecontestquery))
{
$user = $contest['contestname'];
if I print $contest, it displays all the contest names on the top of my php page, so I'm sure the query is right.

For the template, I have this (and I think this is what needs to be changed:
<tr><td class="alt2" align="center" colspan="8">Select an active contest<script type="text/javascript">
<!--
function go1(){
if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != "none") {
location = document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value
}
}
//-->
</script>
<script type="text/javascript">
<!--
document.write('<form name="selecter1"><select name="select1" size=1>');
document.write('<option value=none>--------------------');
document.write('<option value="$activecontestquery">$user');
// end hiding contents -->
</script>

</td></tr>


Again, I know the code is probably not efficient and way wrong, but it's semi-working. I'm learning as I go, but could sure use some help now. Thanks!

aggiefan
07-04-2006, 03:43 AM
So I'm guessing this is basically impossible (or to hard to do)? Any ideas out there on a possible workaround?

sabret00the
07-04-2006, 11:25 AM
i need the rest of your code for your loop in order to help you. although basically i'm assuming the list constructor needs to be prefixed with a period

$list .= "<li>" . $content . "</li>";

jibious
07-25-2006, 02:41 PM
if you get this working, will you be releasing it? please let me know. thanks.

aggiefan
07-27-2006, 04:27 PM
We plan on releasing our contest, but aren't too sure yet. We may "sell" it for a small donation (nothing like the $50 vbpool is using). I have done a work around for now and got it almost complete (at least the NCAA type one).

The programming isn't the best, but it works. What I have so far is looking good. I expect to have it complete with a few weeks to spare before football season.

jibious
07-27-2006, 08:47 PM
just let me know. if it's good (i'm assuming i can have a look on your site), i will be MORE than happy to contribute a donation. i posted on the vBPool forums with some questions a few days ago but haven't heard anything back. i'm guessing their product, especially for $50, is NOT worth the money.

i'm going to be doing a college football pick 'em, as well, so that's good on your part to do NCAA. huge Auburn fan here.. :-)

aggiefan
07-30-2006, 02:41 AM
We just upgraded to 3.6, so I'm hoping everything ports over to that. I'm nearly complete with the NCAA part. I've heard the changes between 3.5 and 3.6 shouldn't be that different, so I don't think there'll be an issue there.

I'll let you know. Texas A&M fan here -- you can tell by the website, Aggiefans.com. :)