Wordpress foreach loop issue.

Discussion in 'PHP' started by raoraj, Apr 18, 2014.

  1. #1
    i using this code to display radio buttons for selection. somehow the its not working correctly, plz guide on this issue.

    thanks in advance.

        <div class="register-section" id="user-role-section">
        <label for="wp_rar_user_role"><?php echo $this->wp_rar_role_label; ?></label>
        <?php
        foreach($this->wp_selected_rar_roles as $role) {
          ?>
         <input type="radio" name="wp_rar_user_role" id="wp_rar_user_role" class="input select" value="<?php echo $role; ?>" /> <label>
            <?php echo $wp_roles->roles[$role]['name']; ?>
          </label>
          <?php
        }
        ?>
       
        </div>
    
    PHP:
     
    raoraj, Apr 18, 2014 IP
  2. jewels1

    jewels1 Active Member

    Messages:
    118
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    53
    #2
    Can you please tell me what you get when you print_r($this->wp-selected_rar_roles)?

    Also, when you say "it's not working" - what do you mean? are you not getting any inputs shown?
     
    jewels1, Apr 23, 2014 IP
  3. raoraj

    raoraj Well-Known Member

    Messages:
    849
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #3
    i said "its not working correctly,"
    any way got it working now.

    thanks
     
    raoraj, Apr 26, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Then you should elaborate what the actual problem was - and writing "it's not working correctly" doesn't really help us - we can't use your code to show the same problem, since we might not have Wordpress installed, or if we do, we might not have the correct setup.
    And, if you've found the solution, as a courtesy for other people searching for similar solutions, you should post the solution.
     
    PoPSiCLe, Apr 27, 2014 IP
  5. muratdniz

    muratdniz Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #5
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsApplication2
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    int[] dizi = { 5, 10, 15, 20, 25, 30 }; //
    int toplam=0; //
    foreach (int x in dizi) //
    {listbot..
    toplam += x; //
    }
    label1.Text = “Toplamları: ” + toplam;
    }
    }
    }

    [​IMG]

    This forum Foreach cycle is described.

    Loops in the program, which had to be repeated statements or code blocks instead of typing again and again by typing in a single structure or code blocks of statements. In C#, Foreach cycle notation indicating a set of each element of collection or a structure for codes that are cycles that are running.

    (Degisken_tipi Foreach variable in array) {

    //code;
    }

    the variable, in order to keep the number of the elements. Foreach loop cycle provides an opportunity for us use variable. so that is what we want we want sokabiliriz processing. But we cannot work on a cycle. For example, an integer type for the variable listbox components and add to a total program that says let's take it for you.
     
    Last edited by a moderator: May 1, 2014
    muratdniz, Apr 30, 2014 IP
  6. msx

    msx Member

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #6
    maybe you should try to print_r($role) and see what it outputs, looks logical that you output variables from this $role array (like echo $role->something)
     
    msx, May 15, 2014 IP