here i am store the dynamic row values into mysql. i am using jquery and javascript for dynamic rows and auto calculation and then stored to mysql using php coding. that works perfectly. i already added dynamic row value into mysql perfectly. But, now i want to edit the table so how can i fetch the dynamic row? thats my question... basically i know how to retrieve the values from mysql. but i dont know how to retrieve the dynamic row values... 997433b4e5c8fa0790ecff20975c448a
i attached one image. look at this... if user clicks the plus button it will add rows. sometimes user can add 5 rows or 10 rows or 20 rows... these all rows are stored into mysql db successfully and then i assigned a specific reference id for these rows. any idea? how to retrieve dynamic rows using that specific reference id????

Recommended Answers

All 13 Replies

I'm not sure what your asking for.
to get the id of the last insert into the db: mysqli.insert-id
show the code you have problems with

i want to fetch the dynamic rows from mysql. for exampl first (for example slno 1) user adds 10 rows and then second (for example slno2) users add 5 rows. these all rows values stored in mysql. now i want to edit the user details. if i click slno1 means it should show the values of 10 rows or else if i click slno2 means it should show the values of 5 rows. mysql_insert_id(); its not a problem. i already assigned specific values for these rows... FETCH DYNAMIC RECORDS USING ARRAY...

store user corrsponding user id too in table means user1 add 5 rows then every row has userid (user1) with the help of this user id you can fetch rows of perticular user

What are your db-tables look like?
post your code

@ pzuurveen :

index.php

<td><input type="text" name="slno[]" value="" size="2"></td>
      <td><input type="text" size="10" name="date[]" id="SelectedDate" onClick="GetDate(this);" readonly="readonly"/></td>
      <td><input size="24" type="text" name="particulars[]" value="" placeholder="Description"></td>
      <td><select name="noofnights[]" value="0">
      <option value="empty"></option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
      <option value="10">10</option>
      <option value="11">11</option>
      <option value="12">12</option>
      <option value="13">13</option>
      <option value="14">14</option>
      <option value="15">15</option>
      <option value="16">16</option>
      <option value="17">17</option>
      <option value="18">18</option>
      <option value="19">19</option>
      <option value="20">20</option>
      <option value="21">21</option>
      <option value="22">22</option>
      <option value="23">23</option>
      <option value="24">24</option>
      <option value="25">25</option>
      <option value="26">26</option>
      <option value="27">27</option>
      <option value="28">28</option>
      <option value="29">29</option>
      <option value="30">30</option>
      <option value="31">31</option>
    </select>
        <input size="14" type="text" onKeyUp="return valtxt(this)" name="rate[]" value="0">
        <input size="14" type="text" name="price[]" value="0" readonly="readonly">
<input size="9" type="text" name="tax[]" onKeyUp="return valtxt(this)" value="0">
<input size="1" type="hidden" name="taxtotal[]" value="0" readonly="readonly"></td>

store.php

if (isset($_POST['submit_val']))
{
foreach ( $_POST['slno'] as $key=>$slno )
{
$date = $_POST['date'][$key];
$particulars = $_POST['particulars'][$key];
$c_date = mysql_real_escape_string($date);
$c_slno = mysql_real_escape_string($slno);
$tariff = mysql_query("INSERT INTO ebvouchertariffs ( TariffSlNo, TariffDate)", $link );
}
}

i written this code for dynamic row values inserted into db and some javascript functions too... now i want to fetch the datas using foreach..

Member Avatar for diafol

basically i know how to retrieve the values from mysql. but i dont know how to retrieve the dynamic row values...
how to retrieve dynamic rows using that specific reference id????

So from this I take it you want to retrieve...

$query = "SELECT ... FROM table WHERE id = $id";

You're post was very confusing, so are you looking to display additional records with that form?

If so, you probably need to use the LIMIT clause...

$query = "SELECT ... FROM table LIMIT $start, $amount";

@diafol :
look at this image. this column name is VoucherID_Fk

in that image you can see some VoucherID_Fk values 37,37,37,36,36,36. these three row contains different values in other columns like TariffDate, TariffParticulars, TariffRate etc...,

select & fetch query code :

$tariff_query = mysql_query("SELECT * FROM ebvouchertariffs WHERE VoucherID_Fk = $id");
        $t_row = mysql_fetch_object($tariff_query);
        echo mysql_error();

        <td><?php echo $t_row->TariffDate ?></td>
                <td><?php echo $t_row->TariffParticulars ?></td>

i attached another images look at this...

those 38 number column is VoucherID_Fk. you can see different row values from other rows 10,7 & 900,5000 & 9000,35000 & 6.25,5. so, now i want to fetch records using that VoucherID_Fk. but i got only 1st row values, i didn't get remaining values...
For example i fetch the VoucherID_Fk number 38..

i want output like this..

38 10 900 90000 6.25
38 7 5000 90000 5

but now i got like this..

38 10 900 90000 6.25

i didn't get the all rows of that particular id...????

Member Avatar for diafol

You need to iterate over the resource...

while ($row = mysql_fetch_object($tariff_query)) {
    echo $row->somefield;
    echo $row->someotherfield;
}

So you now get all the records not just the first one.

BTW, if you want to use an object, why not use PDO or mysqli? mysql is dead - or as good as.

@ diafol : c70ac1b3cd3d4aa71885329df2ffa0ab it works. but look at this images. it splits the table. i want to fetch one by one row...

i want like this...

1st row
2nd row
3rd row
4th row

but i got like this...
<table>
1st row
</table>
<table>
2nd row
</table>
<table>
3rd row
</table>
<table>
4th row
</table>
<table>
5th row
</table>

@ diafol : got it. thanks thats my mistake...

How do you add a membership records in java(bluej) First Name, Last Name, phone number. Please can you help me

Member Avatar for diafol

@HMP123

Please post to the correct forum (Java?) and give full details of your query. Your post is insufficient as it is. Include any code that you've written too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.