1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Little help with arrays

Discussion in 'PHP & Perl' started by MoneyMafia, Jul 17, 2008.

  1. MoneyMafia

    MoneyMafia Regular Member

    Joined:
    Dec 2, 2007
    Messages:
    290
    Likes Received:
    310
    I use this to list values from a db:

    Code:
    //+++++++++++++++++++++++++++++++
    // GET REFERRAL RATES(PLANS)
    //+++++++++++++++++++++++++++++++
    function get_ref_rates()
    {
      $plans= array();
      $get = mysql_query("SELECT id,howmany,price,status FROM mdl_config WHERE item LIKE 'referrals' ORDER BY howmany ASC");
      while ($row = mysql_fetch_array($get))
      {
       array_push ($plans, $row);
      }
      return $plans;
    }
    and this to get an array with variables and pass to template:
    Code:
     //---------- GET BUY PURCHASE REFS ITEMS --------
      $plans= array();
      $plans= get_ref_rates();
      //-----------------------------------------------
    Smarty Code:
    Code:
     <tr>
               <td class="fieldsname">» Choose Plan:</td>
               <td class="fieldsname">
                <select class="generalborder" name="plan">
                {section name=c loop=$plans}
                 <option value="{$plans[c].id}" {if $plans[c].id eq $frm.plan}selected{/if}>{$plans[c].howmany} referrals - ${$plans[c].price}</option>
                {/section} 
                </select>
               </td>
              </tr>
    
    Question is .. how do I check the variables sent from the form..
    I dont want to do a new SQL query I want to use the array I've already defined....

    if ($frm['action'] == 'purchase_referrals')
    {
    $errors = array ();
    .....................
    something like (if $plans.id[$frm['plan']]['status'] == 'active') go on..

    the problem is I can not use $plan['$frm['plan']]['status'] coz the first column is the line no ..0 ,1 , 2 etc..
    I think is simple but.. cant figure it out :confused:
     
  2. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    Im not really sure what you are asking. Are you havign trouble getting data from the array to enter into the select dropdown? Or are you having problems getting the data after the form is submitted? Or am I not close at all :)

    If you wouldn't mind clarifying a bit I would be glad to help.
     
  3. MoneyMafia

    MoneyMafia Regular Member

    Joined:
    Dec 2, 2007
    Messages:
    290
    Likes Received:
    310
    Well the form is sending me $frm['plan'] which the plan id..
    I want to do a checking with the plan ID I have it in the array and dont know how to do it
     
  4. dbrown

    dbrown Junior Member

    Joined:
    Dec 26, 2007
    Messages:
    104
    Likes Received:
    181
    here.. plug this into your scripts and it will tell you all the vars and arrays.

    Download this
    http://sismeiro.com/php/class_blackbox.phps

    and insert this into the file you are working with
    Code:
    <?php
     
     require_once('class_blackbox.php');
     
     $debugger=new blackbox();
     
     $t=1;
     $z=11/$c;
     
     $ff='asd';
     
     $d=(33*$z)+$x;
     
      echo "<pre>";
    
      print_r($debugger->data);
     
    ?>
     
  5. barigain

    barigain Junior Member

    Joined:
    Aug 23, 2012
    Messages:
    100
    Likes Received:
    12
    When I send a submission with no message text, I don't even get validation errors: the submission succeeds. You need to narrow down this problem quite significantly as I suspect that you have a few.