vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   rewrite this code (https://vborg.vbsupport.ru/showthread.php?t=60631)

Princeton 01-23-2004 03:21 PM

rewrite this code
 
is there an easier / more productive way to rewrite this code:
PHP Code:

$radio6CHECKED =  ($newpost['radio2']=='1')? HTML_CHECKED""
     
$radio7CHECKED =  ($newpost['radio2']=='2')? HTML_CHECKED""
     
$radio8CHECKED = ($newpost['radio2']=='3')? HTML_CHECKED""
     
$radio9CHECKED = ($newpost['radio2']=='4')? HTML_CHECKED""
     
$radio10CHECKED = ($newpost['radio2']=='5')? HTML_CHECKED""

thank you

NTLDR 01-23-2004 03:30 PM

PHP Code:

switch($newpost['radio2']) {
    
    case 
1:
        
$radio6CHECKED HTML_CHECKED;
        break;
    case 
2:
        
$radio7CHECKED HTML_CHECKED;
        break;
    case 
3:
        
$radio8CHECKED HTML_CHECKED;
        break;
    case 
4:
        
$radio9CHECKED HTML_CHECKED;
        break;
    case 
5:
        
$radio10CHECKED HTML_CHECKED;
        break;


Maynot be more productive, but its another way none the less.

Princeton 01-23-2004 03:44 PM

LOL
thank you NTLDR ... I use switch/case statement but, I'm looking for something shorter/simpler.

Xenon 01-23-2004 10:47 PM

hmm as you use a follow up counter method, this should work also:

PHP Code:

eval('$radio' . ($newpost['radio2'])  . 'CHECKED = HTML_CHECKED;'); 


Princeton 01-24-2004 01:01 AM

I gotta check that out ... thank you.:up:

Princeton 01-24-2004 04:13 PM

Xenon,
I'm not having any luck with the code.:( It's not recognizing which radio button was clicked.

Xenon 01-25-2004 12:30 AM

hmm, wierd, i think it should work...

Princeton 01-25-2004 02:12 AM

I'll rephrase that ... on preview it doesn't recognize which radio was clicked

Xenon 01-25-2004 07:49 PM

ahh :)

that would expalin it :)
i've also had problems with the checked boxes and preview..


All times are GMT. The time now is 03:03 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.01147 seconds
  • Memory Usage 1,730KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete