mysql - PHP Loop row Value -


i'm newbie , have tried best figure out on how solve problem can't it.

i want know how primary key/foreign key value of current row in loop. in current code, primary key of last row. have tried $_post[subject_id] , $_session[subject_id] , nothing happens. please me. should do? in advance!

this php file.

dbconn(); $sql = "select student_id, lastname ||', '|| firstname ||' '|| middlename     name, contact_no tbl_student student_id in (select student_id     tbl_student_block)"; dbclose(); echo "<center>"; insertlistmenu ("select student: ", "student", $sql." order name",     "student_id", "name", "studsearch", "search"); echo "</center>"; echo "<br/>"; $student_id = $_post['student']; if (($_post['studsearch']) == 'search'){     dbconn();     $rs = pg_query("select sj.*, sum(p.paid_amount) total,     sj.subject_fee - sum(p.paid_amount) balance tbl_subject sj,     tbl_payment_details p, tbl_student s, tbl_student_block sb     p.student_block_id = sb.student_block_id ,     s.student_id = sb.student_id , sj.subject_id = sb.subject_id     , sb.student_id = ".$student_id."     group sj.subject_id order sj.subject_id;");     displayrecordset($rs);     dbclose(); }     $_session['studid'] = $_post['student']; if (isset($_post['payment']) && ($_post['payment'] == 'add payment')){     dbconn();     $rsbookedit = pg_query("select sj.description, sj.subject_fee,     sum(p.paid_amount) total, sj.subject_fee - sum(p.paid_amount) balance     tbl_subject sj, tbl_payment_details p, tbl_student s,     tbl_student_block sb p.student_block_id = sb.student_block_id     , s.student_id = sb.student_id , sj.subject_id = sb.subject_id     , sb.student_id = ".$_session['studid']." ,     sb.subject_id = '".$_session['subid']."' group sj.subject_id     order sj.subject_id;");      $r2 = pg_fetch_array($rsbookedit, null, pgsql_assoc);     echo var_dump($r2);     dbclose(); } 

this loop:

<?php     $counter = 1;     while ($r = pg_fetch_array($rs, null, pgsql_assoc)){ ?>     <tr>     <td><?php echo $counter; ?></td>     <td><?php echo $r['subject_id']; ?></td>     <td><?php echo $r['subject_fee']; ?></td>     <td><?php echo $r['total']; ?></td>     <td><?php echo  $r['balance']; ?></td>     <td> <?php     if ($r['balance'] > 0){ ?>         <input type="submit" name="payment" value="add payment" /> <?php     }     else         echo "paid"; ?>     </td>     </tr> <?php     $_session['subid'] = $r['subject_id'];     $counter++;     } ?> 

try pgsql_both on line or can leave parameter blank because optional

while ($r = pg_fetch_array($rs, null, pgsql_both)){ 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -