Page 1 of 1

Copy data from to table

Posted: Thu Jun 07, 2012 3:03 pm
by ruiascensao
Hi,

I have a table that has model details:
standard_details.jpg
When I create a new unit I copy this details to the unidetails table:

Code: Select all

$ut  = nuRunQuery("SELECT * FROM giga_mod_detail WHERE mdetail_id = '$modelID'");

    while($row1 = db_fetch_object($ut)){
	$detailnum = $row1->mod_detail_num;
	$accessory = $row1->mod_detail_name;
	$modtype = $row1->mod_type_id;
	$newrecordID = uniqid('1');
   
	$sql  = "INSERT INTO giga_udetails (";
	$sql .= "giga_udetails_id, udetails_unit_id, udetails_num, udetails_name, udetais_mo_id, udetails_type_id) ";
	$sql .= "VALUES ( ";
	$sql .= "'$newrecordID','$recordID','$detailnum','$accessory','$modelID','$modtype')";
	nuRunQuery($sql);
        nuRunQuery("INSERT INTO acc_counter (acc_text) VALUES ('1')");

        $t  = "UPDATE giga_udetails SET udetails_code = '" . mysql_insert_id() . "' ";
        $t .= "WHERE giga_udetails_id = '$newrecordID'";
        nuRunQuery($t);
   }
The problem is that I'm getting blank records:
unitdetails.jpg
Any idea what is the problem?

Thank You!,
Rui

Re: Copy data from to table

Posted: Tue Jun 12, 2012 2:06 am
by shane
Sorry I cannot see the problem, it could be more data in the source than you are aware of?

Try echoing the response out to the screen as you do the look to see where this is happening

Re: Copy data from to table

Posted: Thu Jun 14, 2012 5:02 am
by admin
rui,

You really need to learn how to debug your work.

If we were to help you, thats all we would do.

Steven

Re: Copy data from to table

Posted: Fri Jun 15, 2012 11:27 am
by ruiascensao
Sorry Steven!

I solve this issue for now just deleting the rows with udetails_num=0.
I will usethe nuDebug() function to correct this.


Best Regards,
Rui

Re: Copy data from to table

Posted: Mon Jun 18, 2012 1:25 am
by admin
Good on you!

Steven