vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Jump Menu (https://vborg.vbsupport.ru/showthread.php?t=67970)

Blue Moose Aaron 08-03-2004 07:19 PM

Jump Menu
 
I want to create a jump menu that will display the id and name of all the records in a certain table. I figured out how to do it with my individual php file, but now Im trying to get it to work with vB and templates.

Any ideas?

Revan 08-03-2004 08:52 PM

This will most likely not work, but you can try this:

In your vb php file put summit like this:
PHP Code:

$options .= "<option value='".$row[contents]."'>".$row[contents]."</option>";
$options .= "<option value='".$row[contents2]."'>".$row[contents2]."</option>"

Then in your template put summit like this:
PHP Code:

<select name="selection">$options</select


hopefully ye get the picture.
if not, then in plain words if you put .= infront of a variable you add it to the var instead of overwriting current value.

Hopefully this wasnt just me talking bs ? ;)

Blue Moose Aaron 08-04-2004 04:27 AM

I originally had it set up like this and it displays all the records (http://www.thekryptonian.com/smallville.php)

PHP Code:

<select onChange="location=options[selectedIndex].value;">
                    <option selected> Choose an Ep  </option>
                              <?
        $result = mysql_query("SELECT * FROM smallville_episode_guide ORDER BY id ASC",$db);
        $php_self = $_SERVER['PHP_SELF'];
        while ($myrow = mysql_fetch_array($result)) {
printf("<option value=\"%s?action=episodeguide&episode=%s\">---%s - %s</option> \n", $php_self, $myrow['id'], $myrow['id'], $myrow['episode_name']);
        }
        
        
      ?></select>

I just need to find out how to make that code work with vB cause its not!

Revan 08-04-2004 02:45 PM

If it works in another php file then it works with vB as well, so your problem is to ave it echo in the template.
maybe summit like this:

In your template:
PHP Code:

<select onChange="location=options[selectedIndex].value;">
                    <
option selectedChoose an Ep  </option>
                    
$options                   
</select

In your php file:
PHP Code:

        $result mysql_query("SELECT * FROM smallville_episode_guide ORDER BY id ASC",$db);
        
$php_self $_SERVER['PHP_SELF'];
        while (
$myrow mysql_fetch_array($result)) {
$options "<option value='%s?action=episodeguide&episode=%s'>---%s - %s</option> \n"$php_self$myrow['id'], $myrow['id'], $myrow['episode_name'];
        } 

Basically just stick all your episode query results into a variable, and have this echo in the template....

Blue Moose Aaron 08-04-2004 08:44 PM

I get an error with that The , coma on this line gets me "<option value='%s?action=episodeguide&episode=%s'>---%s - %s</option> \n", $php_self, $myrow['id'], $myrow['id'], $myrow['episode_name'];

Revan 08-04-2004 10:47 PM

Hm well then just look at other hacks/vb itself and see how they do it.

Take a look at the forumjump stuff for example, this is similar to your issue in the way that its a <select>, and its <option>'s is dynamic ;)

Blue Moose Aaron 08-04-2004 11:16 PM

I am, but I'm having a time finding where forumjumpbits is...

Thanks for your help so far, maybe someone will come along with some idea.

On a positive note I have got it to display, the only problem left is that it is only diplaying one record rather than all of them.

Revan 08-04-2004 11:39 PM

Did you try the .= to print all the results into the variable?
This SHOULD work because its the same concept that saved my ass in the RPG convertion ;)

AN-net 08-05-2004 12:06 AM

you should not hardcode such things;)

here is the html:
HTML Code:

<select onChange="location=options[selectedIndex].value;">
                    <option selected> Choose an Ep  </option>
                    $options                   
</select>

here is php
PHP Code:

eval('$options .= "' fetch_template('templatename') . '";'); 

in that template put:
HTML Code:

<option value="$variable1">$variable2</option>

Blue Moose Aaron 08-05-2004 12:43 AM

Well that worked, but its only displaying one record rather than all of them. Any suggestions?


All times are GMT. The time now is 05:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01344 seconds
  • Memory Usage 1,755KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete