vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   What's wrong with that loop? (https://vborg.vbsupport.ru/showthread.php?t=103997)

Lionel 12-29-2005 08:24 PM

What's wrong with that loop?
 
Please someone help me. The below returns only one checkbox checked.
When I echo the two comparative values $player1[$p1] and $predplayer1 separately, the results are there. So if I have more than one result why is only one checkbox checked?


PHP Code:

 $predplayer1="$playerlname1 $playerfname1";
$player1=unserialize($getplayers1['players1']);
for (
$p1 0$p1 count($player1);$p1++)

if (
$player1[$p1]==$predplayer1){
$checkbox1 ="<input type=\"checkbox\" name=\"predplayer1[]\" value=\"$predplayer1\" checked>";
}
else {
$checkbox1="<input type=\"checkbox\" name=\"predplayer1[]\" value=\"$predplayer1\">";
}



filburt1 12-29-2005 08:44 PM

Other than being really overcomplicated, what does it do?

If you're doing what I think you're doing (naming similar things with similar names, then ending with a number), then stop right now. It's a horrible practice that will bite you and anybody who tries to follow your code in the ass later.

Lionel 12-29-2005 09:05 PM

What does it do? I am trying to populate checkboxes stored in database as serialized. I need to put a checkbox next to each player that is in the serializing.

People come and put their values. Later if they want to edit, the stored values should be at their places.
here

Thanks God this is soccer so since I don't know how to extract that $i value from the array, I ended up doing the below 15 times, hoping that there won't be more than 15 goals in a game



PHP Code:

  if ($predplayer1==$player1[0] OR $predplayer1==$player1[1]  OR $predplayer1==$player1[2] OR $predplayer1==$player1[3] OR $predplayer1==$player1[4] OR $predplayer1==$player1[5] OR $predplayer1==$player1[6]) 



All times are GMT. The time now is 11:05 AM.

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.01604 seconds
  • Memory Usage 1,720KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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