I want to be able to insert the data from a range function into mysql table the range values comes from 2 textfields that are user inputted, for example the user inputs 1 and 50 the range function generates numbers from 1 to 50 in an array, my problem is inserting the numbers into the database table with other values inserted also like user chosen waybill_booklet id which i put into a drop down menu and a hidden value that is for the other foreign key, so basically if the user inputs number 1 and 50, it will insert 1 2 3 4 ... 50 into the database table and also when he chooses booklet numbers it also puts in what id for that booklet number like waybill number = 1, booklet number = 1, and hidden value which is always equal to 4, so the inputted data in the database will be [1 1 4] [2 1 4] [3 1 4] [4 1 4]... [50 1 4]

<?php require_once('../Connections/connect.php'); ?>
<?php

mysql_select_db($database_connect, $connect);
$query_Booklet = "SELECT * FROM tbl_waybill_booklet";
$Booklet = mysql_query($query_Booklet, $connect) or die(mysql_error());
$row_Booklet = mysql_fetch_assoc($Booklet);
$totalRows_Booklet = mysql_num_rows($Booklet);

$booklet = $_POST['waybill_booklet'];
$status = $_POST['status'];
$from = $_POST['from'];
$to = $_POST['to'];
$number = range($from,$to);

print_r($booklet);
print_r($status);
print_r($number);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Waybill</title>
<link rel="shortcut icon" href="../img/icon.ico">
<link rel="stylesheet" type="text/css" href="../css/forms.css" />
</head>

<body>
    <form id="form3" name="form1" method="post" action="">
        <p>From:
        <input type="text" name="from" id="form_number" class="from" /> 
        - To:
        <input type="text" name="to" id="form_number" class="to" />
        </p>
        <p>Waybill Booklet:
        <select name="waybill_booklet[]" id="form_list">
            <?php
                do {  
            ?>
            <option value="<?php echo $row_Booklet['id_waybill_booklet']?>"><?php echo $row_Booklet['booklet_no']?></option>
            <?php
                } while ($row_Booklet = mysql_fetch_assoc($Booklet));
                $rows = mysql_num_rows($Booklet);
                if($rows > 0) {
                mysql_data_seek($Booklet, 0);
                $row_Booklet = mysql_fetch_assoc($Booklet);
                }
            ?>
        </select>
        </p>
        <p>
        <input type="hidden" name="status[]" value="4" />
        <input type="submit" name="button" id="form_button" value="OK!" />
        </p>
    </form>

</body>
</html>
<?php
mysql_free_result($Booklet);
?>

whats the problem?
are you getting an error?

wheres your insert code?

no one here will write the code for you, we will help you debug it though

no error though i just need a syntax for the insertion, i know how to insert but i dont know how to insert this kind of array, i have no syntax for it yet, im a beginner in webdeveloping

simple solution: loop through the array from start to end and insert once for each step through

loop i = start to stop {
insert i, static val, staticval here
}
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.