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