i want submit a form continuosly selecting some values from the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rukky Dollars
    New Member
    • Sep 2010
    • 1

    i want submit a form continuosly selecting some values from the database

    i want this form to loop through counting the number of people in d table and geting the next name after submiting the first. i really need help

    [<?php $getcat = mysql_query("SE LECT * FROM stud_registrati on where entry_class ='$g'");
    $rss=mysql_fetc h_array($getcat );

    ?>

    <table width="549">
    <tr>
    <td height="123" valign="top"><f orm id="form1" method="post" action="control .php?my=addscor e">
    <table width="541" cellpadding="0" cellspacing="1" >
    <tr>
    <td height="12" colspan="4"><st rong>Name:</strong>&nbsp;&n bsp;<? echo $rss['title']; ?> &nbsp;&nbsp; <? echo $rss['surname']; ?>&nbsp;&nbsp;< ? echo $rss['middlename']; ?>&nbsp;&nbsp;< ? echo $rss['firstname']; ?></td>
    <td colspan="3"><st rong>Term:</strong>&nbsp;&n bsp;<? echo $rss['entry_term']; ?><? echo $cou;?></td>
    </tr>
    <tr>
    <td height="13" colspan="4"><st rong>Userid:</strong>&nbsp;&n bsp;<? echo $rss['userid']; ?></td>
    <td colspan="3"><st rong>Session:</strong> &nbsp;&nbsp; <? echo $rss['entry_session']; ?></td>]
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    Welcome to Bytes. Please use [code ][/code] tags around your code.
    If I understand correctly you can do this several different ways. I would guess that seeing as you're only doing one record at a time, you want to use mysql_fetch_row () instead of mysql_fetch_arr ay(). Also, you want to look into using LIMIT in your query statements to save your server processor time. So you would do something like:
    Code:
    $getcat = mysql_query("SELECT * FROM stud_registration WHERE entry_class ='$g' LIMIT 1");
    $rss=mysql_fetch_row($getcat);
    Now to after a user submits a form you need something to tell you where you are up to in the list. So I would say make a hidden <input /> to include which number you're upto (which can be accessed by $_POST['number'] or something). This would change your code to something like:
    Code:
    if ($_POST['number']>0) {
    $number = $_POST['number'];
    $getcat = mysql_query("SELECT * FROM stud_registration WHERE entry_class ='$g' LIMIT $number,1");
    // This skips $number records and returns 1 record
    } else {
    $getcat = mysql_query("SELECT * FROM stud_registration WHERE entry_class ='$g' LIMIT 1");
    }
    $rss=mysql_fetch_row($getcat);
    The other option is to save the array you get from mysql_fetch_arr ay($getcat) into the $_SESSION variable and then call out the "sub-arrays" depending on what number form you're on. This saves your server from handling so many calls, but will not be quite as flexible as fresh calls (if data is updated after you have made the first and only mysql_fetch).

    Comment

    Working...