0

hi there..
I using for loop to increment the column in my page. through this increment, I want it to insert to the database. But what I'm getting is the last value only. can someone help me?
this is my supplier_quo.php which when we click submit button, it will go to report_supplier.php

$j=30;
$display_columns =$j++; 
$query = "SELECT * FROM supplier_details WHERE `details_status` = 'in process'";

// We do the query, and find out how many items we'll need to list. 
$result = mysql_query($query); 
$count = mysql_numrows($result); 


$padding =($display_columns-1)-(($count-1)%$display_columns); 



echo '<table border="1" >'; 
for($i=0; $i<$count; $i++) 
{    
    if($i%$display_columns == 0) 
        echo '<tr>'; 
  
    echo '<td width="40" valign="center">'; 
    
	//echo $i+1;
	$no=$i+1;
	echo"<input type=\"text\"  size=\"2.5\" name=\"supplier_no\"value= \""  .$no ."\">";
    echo '</td>'; 

    //Whenever $i is one less than a multiple of $display_columns, 
    // it's a sign that we're hitting the end of the current row. 
    if($i%$display_columns == $display_columns) 
        echo '</td>'; 
}

report_supplier.php

<?php
session_start();
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("supplier", $con);

$final = $_POST['reportTotal'];
$supplier_no = $_POST['supplier_no'];


// loop through array
$num = count($final); 
$number = $num-1;
for ($i=0; $i<=$number; $i++)
{
    
          $itno = $final[$i];

    $query = "INSERT INTO supplier_report (report_value,report_supplier) 
               VALUES ('$itno','$sno') ";
mysql_query($query) or die(mysql_error());

	
	}
	echo "<center>Please proceed to this link</br>";
	echo "<center><a href= report_details.php>Continue</strong></br>";
mysql_close();
?>
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by just_me
0

sorry, guys!
I can fixed this problem.
thanks and regards!
:)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.