Php recordset outputting last value from while loop

Hi all,
I have an issue with a site I am making which lists radio buttons which are a set of donation options (some with predefined prices some with user dependant).
I used jQuery to populate a textbox with the value of the radio buttons so the person does not need to enter a price they want to donate.
The issue I am having is that I want the page to carry across the fund_id (which is the primary key) to the next page.
Currently the do / while loop goes through all of the recordset and passes across the last record's fund_id.
Please see my code below:
$(function () {
$('input.radioButton').click(function () {
var checkedradio = $('[name="fund"]:radio:checked').val();
  $('#totalPrice').val(checkedradio);
And
<h3>General</h3>
<?php do { ?>
  <label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_general['fund_price']; ?>" id="<?php echo $row_cat_general['fund_name']; ?>" /><?php echo $row_cat_general['fund_name']; ?> <?php if ($row_cat_general['fund_price']!="") { ?>- &pound;<?php echo $row_cat_general['fund_price']; ?><?php } else {?> <?php };?></label>
  <br />
  <?php } while ($row_cat_general = mysql_fetch_assoc($cat_general)); ?>
<h3>Sponsorship</h3>
<?php do { ?>
  <label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_sponsorship['fund_price']; ?>" /><?php echo $row_cat_sponsorship['fund_name']; ?> <?php if ($row_cat_sponsorship['fund_price']!="") { ?>- &pound;<?php echo $row_cat_sponsorship['fund_price']; ?><?php } else {?> <?php };?></label>
  <br />
  <?php } while ($row_cat_sponsorship = mysql_fetch_assoc($cat_sponsorship)); ?>
<h3>Seasonal</h3>
<?php do { ?>
  <label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_seasonal['fund_price']; ?>" /><?php echo $row_cat_seasonal['fund_name']; ?> <?php if ($row_cat_seasonal['fund_price']!="") { ?>- &pound;<?php echo $row_cat_seasonal['fund_price']; ?><?php } else {?> <?php };?></label>
  <br />
  <?php } while ($row_cat_seasonal = mysql_fetch_assoc($cat_seasonal)); ?> 
<br />
<span id="sprytextfield1">
<label>Enter Amount:
<input name="total" type="text" id="totalPrice" />
</label>
<span class="textfieldRequiredMsg">A donation amount is required.</span></span><br />
<input name="fund_id" type="hidden" value="<?php echo $row_cat_general['fund_id']; ?>" id="fund_id" />
<input name="button" type="submit" value="Select" />      
I hope this doesnt look weird, once I have post this.
Is there a way I can populate "totalPrice" input box AND have "fund_id" hidden field populated with the fund_id of the selected radio button?
Thanks for your help.

Hi,
I have tried this:
$(function () {
$('input.radioButton').click(function () {
var checkedradio = $('[name="fund"]:radio:checked').val();
  var fundidbox = $('[name="fund_id"]').val();
  $('#totalPrice').val(checkedradio);
  $('#fund_id').val(fundidbox);
  alert($("#fund_id").val());

Similar Messages

  • Last value from a loop and values inside the loop

    Hi
    Sorry about the confusing heading above, but its late at night and better words do not occur to me rightaway. Let me explain my situation.
    I have a single instrument (a voltage source) that is being swept from one value to another for an experiment. It has three VI's : 1. enable o/p. 2. Set a voltage output level. 3. diable o/p.
    I am using the error in and error out pins of instrument vis to properly sequence operations. I connect the error out pin of VI 1 to the error in pin of VI 2. Each of these errors is a cluster of three values.
    When I try to wire the error out from VI 2 inside the loop to VI 3 outside the loop, the wiring breaks as I am then trying to connect an array (a 1 dimensional n member array of error outs) to a single error in pin. Trying to connect it to an array outside the loop is obviously the same. (I am making an assumption here - while the loop is running, I do not need to make certain of the sequencing of operations by putting a feedback node on VI 2 - that would mean something quite different in any case.).
    So, how do I pass the last value (in this case, the error out cluster from the last stage) to error in pin of VI 3 ?
    I have read that it might be possible using shift registers. I am quite new to LabVIEW. A somewhat detailed description of what I need to do would be nice.
    Thanks.

    Hello,
    There are basically two options:
    Handle the errors outside the for-loop
    Handle the errors inside the for-loop
    For you solution 1 is the easiest achievable, after the for loop use the 'Merge Errors' VI this will change the 1d-array into a cluster. The downside is that if an error occured later states of the loops don't know this
    Solution 2 uses the shift register you mentioned. To use this you have to right-click on the right hand-side tunnel of the error wire (where it leaves the for-loop) and select shift register, sequentially your mouse pointer changes into an downpointed arrow, click on the entry tunnel on the left of the for-loop. What happens is that an error in the for loop is remembered into the next iteration (use execution highlighting to watch these)
    Here is some code:
    A good start might be:
    The link to the LabVIEW Learning Center is here
    Ton
    Message Edited by TonP on 09-25-2006 08:01 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Example_BD.png ‏5 KB

  • How to get the last error for while loop?

    How to get the last error for while loop? I just want transfer the last error for while loop, but the program use the shift register shift all error every cycle.

    What do you mean by "get" and "transfer"?
    If the shift register is not what you want, use a plan tunnel instead.
    Typically, programmers are interested in the first, not last, error.
    Can you show us your code so we have a better idea what you are trying to?
    LabVIEW Champion . Do more with less code and in less time .

  • How to get updated values from the loops while they are running

    Hello,
            I am having difficulty solving a very basic problem, how to access the updated values from the 'FOR loop' while its running?  Basically, the VI  I am currently working on calls two sub VIs. Each sub VI has a for loop, and both VIs may or may not run for same number of iterations. My goal is to read the values at each terminal inside the loop of both sub VIs, in the Main VI. I tried to achieve it using Global Variables, but in main VI it displays only the last iteration value from both sub VIs. Could anyone please tell me whrere am I going wrong? Is there any other/better way to achieve this.
    I appreciate any input on this issue.  
    Kudos are (always) welcome for the good post. :-)
    Solved!
    Go to Solution.

    Dennis,
                In attached VI, I can see the values changing in the sub VI from the main VI with the numeric indicator whose reference is passed on to the sub VI. Now if I wanted to store or use those values how do I do that? I tried to chnge the indicator to control and read from it (in the attached VI) , but the the indicator updates only once. Tried to create a property node and read the Value from it and it didn't work either.
    Thanks in Advance!
    -Nilesh
    Kudos are (always) welcome for the good post. :-)
    Attachments:
    main-1.vi ‏8 KB
    sub-1.vi ‏9 KB

  • How should I set up my VI so that I can use the linear fit coefficient data analysis program, when my values are coming from while loops within a sequence structure?

    I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
    There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
    t.
    If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
    Thanks,
    Karinne.

    I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
    Stu

  • Plot XY graph from while loop

    I am trying to make a curve tracer with a DC power supply, DAQ, and Labview 7.1. Everything is ok, until I want to plot an x-y plot from a while loop. I can do this function fine using a for loop and cluster cells, but I need the while loop for the interruption function. When I change to the while loop, it had data formating issues, but I believe I have it to something that should work. It seems like my xy plots want to graph (the auto scale moves the axis respectively) but I do not get a line. I'm not sure if Labview is seing this as just one point and not an array, or if there is a labview bug. Attached is my code with a few different trials to make an xy plot. If anyone can be of help I would be very thankful.
    -Jon
    Attachments:
    Curve_trace_w_relays_while.vi ‏122 KB

    If it works in a FOR loop, but nor in a while loop, most likely your output tunnels are not autoindexing (FOR: on by default, WHILE: off by default). Right-click on the output tunnels and select "enable indexing".
    If you want to watch your graph update during the while loop, you could accumulate your x and y data in a shift register and graph it. (See attached modification).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Curve_trace_w_relays_whileMOD.vi ‏74 KB

  • Variable in loop is retaing values from previous loop

    Just wondering if anyone can see at a glance what I going wrong here.
    I have the following part of a script which is imbedded in another while loop which loops through 5 different items defined by 'accomm_id';
    while ($db_field = mysql_fetch_assoc($result)) {
    $SQLx = "SELECT price_from FROM AN_pricetable WHERE accomm_id = " . $db_field['accomm_id'];
    $resultx = mysql_query($SQLx);
    while($row=mysql_fetch_assoc($resultx))
      $price_from[] = $row['price_from'];
      //  do stuff with other column
      //  data if we want
    $pricefrom = min($price_from);
    $temp = $price_from;
    sort($temp, SORT_NUMERIC);
    foreach ($temp as $value) {
    if ($value > 0){ $pricefrom = $value; break;}}
    if ($pricefrom == 0){
              $pricefrom = "TBC";}
    The script is supposed to find the lowest price for the particular accomm_id that it is looping through at the time.
    The problem is that once the 'lowest price' for the item with the lowest 'lowest price' of all 5 accomms has been found, the following items take on that price, instead of their own particular lowest price. Somehow the '$pricefrom' value is being carried through to the next loop.
    The database has several entries for each accomm_id, all with different prices in the 'price_from' field. What I'm trying to find is the lowest for each accomm_id.
    Hopefully this is something obvious that I've missed, I just can't see why it won't work!
    Thanks

    As and alternative I tried;
    $SQLx = "SELECT MIN(price_from) AS minimumprice FROM AN_pricetable WHERE accomm_id = " . $db_field['accomm_id'];
    $resultx = mysql_query($SQLx);
    $pricefrom = mysql_result($resultx,$i,'minimumprice');
    if ($pricefrom == 0){
              $pricefrom = "TBC";}
    But for some reason it is not returning the minimum for any of the 5 accomms. For example one accom has four rows of prices, 8, 12, 50 and 7, and it is returning 12 as the MIN. What am I doing wrong here?
    Thanks

  • Display last value from a row or column?

    I'm using Numbers 09 and want to display the last value entered in a column in another table.
    For example in Table A I have columns set up by date with simple sums at the bottom of each column. I add new sums every day depending on the values from that day. What I'd like to do is get the last daily total and enter that value into another table called Table B. Is there a formula that will do that?
    If I'm not being clear enough please let me know what additional information you need and I will be happy to provide it.
    Thanks,
    rkaufmann87

    rkaufmann87 wrote:
    Hi Barry,
    Thanks for posting the example, not quite though. In your sample Table A is transferring all the totals to Table B. What I'd like is as I enter the data in the columns in Table A Table B then picks up the latest update in a single cell. For example lets say Table A's Column A is May 1 and the total is 45, let's say that sum is placed in A15. Table B automatically picks up A15 from Table A and makes a duplicate in Table B cell A1, then the next day Table A's Column B is May 2 and the total is 90 (cell B15), then Table B senses the latest total is 90 and enters that in cell A1 again. Is this possible?
    Here's another go.
    Table 1 has a second Header row added (row 2) Cells in this row contain the formula
    =IF(A1=MAX($1:1),COLUMN(),"")
    Which returns the column number of the cell in row 1 containing the latest date. (4) This number is used by Table 2 to determine the column from which to return the total in the bottom (footer) row. (see below)
    A1 in Table 2 and Table 3 contain the same formula:
    =MAX(Table 1 :: $1:1)
    This returns the latest date from row 1 of Table 1.
    A2 in Table 2 and Table 3 contain formulas that return the value in the bottom cell of the column containing the latest date in row 1.
    Table 2:   =OFFSET(Table 1 :: $A$1,ROWS('May 1, 2010')-1,MAX(Table 1 :: $2:2)-1)
    Table 3:   =OFFSET(Table 1 :: $A$1,ROWS('May 1, 2010')-1,COUNT(Table 1 :: $1:1)-1)
    Both use the same base ($A$1) and the same row offset (ROWS('May 1, 2010')-1) to reach the bottom row of Table 1.
    Table 2 uses the maximum (and only) numerical value in row 2 of Table 1 ( MAX(Table 1 :: $2:2) ), then subtracts 1 to reach the fourth column of table 1.
    Table 3 uses the same means to determine the row offset, but counts the number of dates entered into row 1 of Table 1 ( COUNT(Table 1 :: $1:1) ), then subtracts 1 to reach the same cell.
    I prefer the method in Table 3 because it avoids the need for the second Header row and the possibility of overwriting the formulas in that row. (Row 2 of Table 1 may be deleted without affecting Table 3.) It does require that there be no empty cells in Row 1 from Column A to the column containing the latest date.
    Regards,
    Barry

  • How to get both, the ResultSet and Output (return value) from Oracle Stored Procedure

    Hi! I am doing a conversion from MSSQL to Oracle with C++ and MFC ODBC. Any comment is appreciated!! I have Oracle 8i and Oracle ODBC 8.1.6 installed.
    My question is how to retrieve the return value AND ALSO the resultSet at the same time by using Oracle function without modifying my souce codes (except puttting mypackage. string infron of my procedure name, see below).
    -- My source code in C++ with MSSQL ....
    sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    Where CustoemrList is a Crecordset object...
    IN DoFieldExchange(CFieldExchange* pFX) I have ...
    //{{AFX_FIELD_MAP(CQOSDB_Group)
    pFX->SetFieldType(CFieldExchange::outputColumn);
    RFX_Long(pFX, T("Name"), mCustoemrName);
    //}}AFX_FIELD_MAP
    // output parameter
    pFX->SetFieldType( CFieldExchange::outputParam );
    RFX_Int( pFX, T("IndexCount"), mCustomerNumber);
    -- m_CustomerNumber is where i store the return value!!!
    -- In Oracle Version, i have similar codes with ...
    sqlStr.Format("{? = call mypackage.ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    -- I have oracle package/Body codes as following...
    create or replace package mypackage
    as
    type group_rct is ref cursor;
    Function listgroups(
    nameID NUMBER ,
    RC1 IN OUT Mypackage.group_rct ) return int;
    end;
    Create or replace package body mypackage
    as
    Function listgroups(
    NameID NUMBER ,
    RC1 IN OUT Mypackage.group_rct )return int
    IS
    BEGIN
    OPEN RC1 FOR SELECT Name
    from Customer
    WHERE ID = NameIDEND ListGroups;
    END
    return 7;
    END listgroups;
    END MyPackage;
    Ive simplified my codes a bit....
    null

    yes, it is exactly what i want to do and I am using Oracle ODBC driver.
    I tried using procedure with 1 OUT var fo numeric value and the other IN OUT ref cursor var instead of function, but error occurs when I called it from the application. It give me a memory ecxception error!!
    sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    it seems to me that the ? marker var is making all the trouble... can you please give me any more comment on this?? thanks!
    null

  • Writing thermocoup​le data to measuremen​t file from while loop

    Hello,
    I'm trying to write thermocouple data that has already been filtered into a measurement file.  My code works, but has many zero-time entries (probably from the filtering aspect), and some of the non-zero-time entries are even out of sequence (my output file is attached as well as my VI.)  I'd love any help regarding getting this to work!
    Thanks in advance,
    Megan
    Attachments:
    FrontPanel.jpg ‏211 KB
    ThermocoupleDAQ_IOrtiz.vi ‏67 KB
    test1.csv ‏63 KB

    Hi Megan,
    do you really need to sample thermocouple data at 1kHz? How fast does the temperature change - and how fast do thermocouples react on that temp change? (Which sample rate is recommended for your hardware?)
    Are your filter settings reasonable? "TC2 unfiltered" looks quite ok, while the "filtered" graph looks awful (atleast for a TC measurement)…
    And you should definitely fetch a constant number of samples from DAQmxRead. Usually you read 1/10th of the sample rate, so reading 100 samples for 1kHz sample rate!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Read single value within while loop

    Hi,
    I have a setup with one output, driving a coil.
    I then have two inputs: one to measure the voltage of my coil (the actual voltage) and the second to measure the voltage of a sensor mounted close to the coil.
    The setup works fine to monitor both channels continuously, however, I want to monitor the second value only once every 5 seconds.
    How can I go about doing this? Every 5 seconds I just want a single measurement from the second channel.

    You haven't given us any info on your device, but I assume it's not super-fancy and can change sample rates per channel.
    This article here explains what you want to do. Your device has a single clock, so you're essentially limited to (forces to match?) your highest sampling rate requirement with all channels and then down-sample from there if you don't want all of the data for some of the other channels.

  • How to exit from while loop

    Hi
        I want to exit from loop if error is encountered.
    THanks

    Hi Sonu,
    This is not a question related to the SDK. This is more of a coding question you should probably try something like StackOverflow or MSDN forums for that next time.
    Regarding your question it depends on the language you are using. If you are using c# you can use the keyword "break;" inside an if that checks for the error. In VB you can use "Exit For" or "Exit While".
    Best regards,
    Pedro Magueija

  • Quit from while loop inside a vi that run a while loop

    Hello,
    this is just an example
    i have a led that blink inside a subvi and i what to stop it form the ui of the user (MainHelp.vi)
    but because the subvihelp.vi dont know the stop button it will not stop when i klick on the stop button
    How i can work it out with out using global Var
    thanks for your replay.
    Attachments:
    MainHelp.vi ‏9 KB
    SubVIHelp.vi ‏9 KB

    Hi
    Here is one method to stop a blinking VI in a SubVI.  I tried not to change your version of how the blinking works.  Since the subVI is running continuously this example calls the VI using static reference and using the control names.  You could also use a queue to pass values to the subVI controls.
    Your original VI has a lot of stuff that made no sense, so I cleaned them all out or up, so to speak.
    Good Luck.
    Mark Ramsdale
    Attachments:
    MainHelp.vi ‏12 KB
    SubVIHelp.vi ‏9 KB

  • How to export a continous waveform data from a while loop?

    Hello there,
    I need to add noise signal to my waveform which is read from a binary file. I use noise generate vi (deleted the density part) from NI example as my sub VI, and put it into a while loop in order to get the continous noise signal, but I don't know how to export this data. There's no waveform come out from the noise waveform output tunnel (on the while loop). I used output tunnel, didn't work, tried shift register, didn't work... Can anybody help?
    Also, how to fix the dt problem for the noise generate vi and my original data ( from binarty file)
    Thanks in advance!
    Wendy

    hi
    I think notifier can do the trick (an example is shown in the master-slave template).
    Another possibility can be a FG (or action engine, look for the nugget ActionEngine, it will change your LV-coding life !)
    N

  • How can I access the value of a loop index outside the loop?

    I have a sequence structure in Labview 8.6.  At one frame of the sequence I have a while loop.  The loop runs for a while and then stops and the program then moves to the next frame of the sequence.  Several frames further on down the sequence I have a cluster, the elements of which are outputs on the front panel.  The index of the mentioned loop is one of the cluster elements, an numeric output.  While the loop is running, I want the index to be displayed on the front panel in the output contained in the cluster.  How can I do this?

    The easiest way to do this is to use a local variable of your cluster.  You'll need one copy set to read; connect that to a bundle by name, bundle in your index value from the loop, and wire the bundle output to a write copy of your local variable.  You can create a local variable by right-clicking on the cluster terminal (in the block diagram) and choosing create local variable.  You can change the local variable to read or write by right-clicking on it.
    However, in general the use of both local variables and sequence structures is discouraged, and the right solution may be to rewrite your code with a while loop containing a case structure in which you update the cluster every time through the loop.  This will look like a state machine; you'll also need a shift register in place of the loop iteration counter.  If you post your code (ideally the VI, but if not then a screenshot of the block diagram) then we can provide more useful assistance.

Maybe you are looking for