Hello! I have few problems. I hope you will understand me and can help me :)

1st - I have large input form, so if i press sumbit button then it makes large query thats slows down my page and database is overload, in form is somewhere about 180 colums. (And rows with data be somewhere about 120 rows) so its too large for one table.

Then comes idea - if i split my query to tree parts one is for general part(1st - table ) another for second part(2st - table) and the last one as for information(3st - table).
So my question is can it be done? And how? (i will add my source bellow)

2st - In this Form i have image upload and thats piss me of :@ I need to upload to 10 pictures, but sometime i need upload only 1-4 pictures, but if i dont upload 10 pictures, for example only 2 its gives me error thats picture isn't selected. (I have try meny scripts and there all the same if its allow stay white space then its dont give url to my database, so i cant figure it how that could be done)

3st- In my form is 2 colums for Car manufacture and car model - i have seen some script that when you choose car manufactur its shows car model list only for that manufactur. I sopose its javascript but i don't know. (I have think about <option> tag)

So i hope you will understand me, if not write commentar and i will try explain.

add.php_1st_add.php_2st_add.php_3st_

You can see the demo in my site url : http://auto-part.lv/autonets.lv/lv/admin/add.php (For demo use only, and please dont press sumbit ;) )

  1. Yes, you can split them up, and change your query to update only part of a table.
  2. You'll need to show your upload code, because this shouldn't be a problem.
  3. Yes, it needs Javascript and an AJAX call to retrieve the information.

Below is two functions which can be used for insert and update tables.
When you have large table you can try it, you need to pass array to function as shown in example.
I know it is off to your question but this code may help you.

<?
//======= function for insert into database =========
function insert($tbl,$arr)
{
    $sql = " INSERT into $tbl set ";
    foreach($arr as $key=>$val)
    {
        $sql.=" `$key` = '$val' ,";
    }
    $sql = substr($sql, 0, -1); 
    mysql_query($sql) or die( '<br /><strong>Insert Query: </strong>'.$sql.'<br /><br /><strong>Error: </strong>'.mysql_error());
    return mysql_insert_id();   
}
//======== function for updating value ===========
function update($tbl,$arr,$where='')
{
    $sql = " UPDATE $tbl set ";
    foreach($arr as $key=>$val)
    {
        $sql.=" `$key` = '$val' ,";
    }
    $sql = substr($sql, 0, -1); 

    if($where != '')
        $sql.= ' WHERE '.$where;
    $res = mysql_query($sql) or die( '<br /><strong>Update Query: </strong>'.$sql.'<br /><br /><strong>Error: </strong>'.mysql_error());
    return $res ;
}
//=== insert user ======
$tbl = 'user';
$data = array();
$data['firstname'] = $_POST['firstname'];
$data['lastname'] = $_POST['lastname'];
$user_id = insert($tbl,$data);

//=== update user ======
$tbl = 'user';
$data = array();
$data['address'] = $_POST['address'];
$data['zipcode'] = $_POST['zipcode'];
$data['subject'] = $_POST['subject'];
$user_id = update($tbl,$data,"user_id=$user_id");

?>
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.