Little help with arrays

Daniel-MD

Regular Member
Joined
Dec 2, 2007
Messages
355
Reaction score
339
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:
 
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.
 
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
 
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);
 
?>
 
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.
 
Back
Top