Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Insert a multiple data in multiple table in MYSQL

Question:

Yung mga tables (amount, description details, model, qty, unitprice) ay may tig-10 na columns?

amount = columns a1, a2, a3, a4, a5, a6, a7, a8, a9
description = columns d1, d2, d3, d4, d5, d6, d7, d8, d9


tama ba pagkakaintindi ko? Or baka mali ang implementation mo? paki post nga ang table structure mo
 
Pa-post ng table structure mo. Tsaka bakit ganun?
 

Attachments

  • data.png
    data.png
    111.2 KB · Views: 31
  • des.PNG
    des.PNG
    168.1 KB · Views: 15
  • amount.PNG
    amount.PNG
    167.9 KB · Views: 8
Last edited:
ts paclear ng tanong
ang gusto mo ba mangyare is isang insert nalang sa database from the table? tama ba? tinatanong mo kung tama yung query para mainsert mo lahat?
 
tama naman cya sa pagkakaintindi ko.. separated by semicolon naman.. havent tried mysqli but okay naman cya sa mysql lang.. ano ba ang error dto? if ever it didnt match your expectations.
 
oo sir parang ganon

- - - Updated - - -

tama naman cya sa pagkakaintindi ko.. separated by semicolon naman.. havent tried mysqli but okay naman cya sa mysql lang.. ano ba ang error dto? if ever it didnt match your expectations.

nd sya napasok sa table ng database sir

- - - Updated - - -

ts paclear ng tanong
ang gusto mo ba mangyare is isang insert nalang sa database from the table? tama ba? tinatanong mo kung tama yung query para mainsert mo lahat?

Yes sir nga lng nd sya napasok sa db ko
 
Please do enlighten me:

- kapag nag insert ka ba ng record sa tables (amount, description, details, model, etc), yung Nos. 1-9 ay isasalpak mo as 1 record for table amount, then 1 record din sa description, and so on?
- what if 3 items ang lalagyan ko ng value? Halimbawa, Nos. 1, 5, & 7 lang lalagyan ko, kapag nag-insert ba sa table amount, ang malalagyan lang ay yung a1, a5, at a7?
- what if 10 items ang gusto ko ilagay?

I was just trying to process how you want your solutions to work.

- - - Updated - - -

Up ko lang ito para sa TS. Paki-paliwanag lang yung structure. Meron kasi ako dito solution na mas madali at mas organized.
 
Last edited:
Please do enlighten me:

- kapag nag insert ka ba ng record sa tables (amount, description, details, model, etc), yung Nos. 1-9 ay isasalpak mo as 1 record for table amount, then 1 record din sa description, and so on?
- what if 3 items ang lalagyan ko ng value? Halimbawa, Nos. 1, 5, & 7 lang lalagyan ko, kapag nag-insert ba sa table amount, ang malalagyan lang ay yung a1, a5, at a7?
- what if 10 items ang gusto ko ilagay?

I was just trying to process how you want your solutions to work.

- - - Updated - - -

Up ko lang ito para sa TS. Paki-paliwanag lang yung structure. Meron kasi ako dito solution na mas madali at mas organized.

hindi po sya yung sinasabi nyo kung number 7 ako mag lalagay 7 lng ung nasa table nya Pero sir pwede din ganun sir mas maganda kc un sir
 
Last edited:
TS, bakit ganun table structure mo? Hiwahiwalay talaga amount, desc, details, model???

Diba dapat ganto TS para manageable yung data mo? Correct me if I'm wrong.

View attachment 339573

 

Attachments

  • 2018-03-16_22h12_12.png
    2018-03-16_22h12_12.png
    6.9 KB · Views: 6
Last edited:
^

Yan na nga yung reason kung bakit dun sa 2 previous replies ko sa thread na ito ay kinukulit ko sya to display the table structure at liwanagin kung bakit yung ang gusto nya gawin solution. Since ayaw nya at gusto nya ituloy sa ganyan, hinayaan ko na lang. Ako pa ba magpupumilit.
 
Pagmultiple transaction gagawin mo sa database, use Transaction. Commit if no errors, Rollback if may error. Ganyan ginagawa ko kapag nag insert o update ako sa multiple tables.

- - - Updated - - -

TS, bakit ganun table structure mo? Hiwahiwalay talaga amount, desc, details, model???

Diba dapat ganto TS para manageable yung data mo? Correct me if I'm wrong.

View attachment 1249599




Ang ibig nya sabihin nyan e ung actual price ng item. then ung total price ng transaction.
Parang sa LBC magpapadala ka ng item. Tatanungin ka muna kung magkano value ng item mo. Then saka lalabas din ung total na transaction amount mo sa LBC.
Tingin ko ganyan ibig sabihin ng tables nya :)
 
Ang ibig nya sabihin nyan e ung actual price ng item. then ung total price ng transaction.
Parang sa LBC magpapadala ka ng item. Tatanungin ka muna kung magkano value ng item mo. Then saka lalabas din ung total na transaction amount mo sa LBC.
Tingin ko ganyan ibig sabihin ng tables nya :)

Edi dapat sir bukod ang table nya ng TRANSACTIONS at ITEM
 
Guys tama ba yung query ko pag mag iinput ng multiple data sa madaming table

View attachment 1249305

Then eto ung pag iiputan ko ng mga data
View attachment 1249306

Boss gumamit ka ng multiple insert na command.
========================
for MySQLi(procedural)
========================
$username = "root";
$password = "";
$database = "mysqltutorial";

// Create connection
$conn = mysqli_connect($server, $username, $password, $database);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

// sql to Insert record table
$sql = "INSERT INTO tblpeople (LNAME, FNAME, ADDRESS)
VALUES ('Villanueva', 'Joken', 'Kabankalan City');";
$sql .= "INSERT INTO tblpeople (LNAME, FNAME, ADDRESS)
VALUES ('Batuto', 'Erick Jason', 'Cebu City');";
$sql .= "INSERT INTO tblpeople (LNAME, FNAME, ADDRESS)
VALUES ('Drapite', 'Bryan', 'Kabankalan City');";

if (mysqli_multi_query($conn, $sql)) {

echo "New record created successfully!";
} else {
echo "Error: " . $sql . "
" . mysqli_error($conn);
}

mysqli_close($conn);
?>
========================
ito yung way using MYQLi (OOP)
========================
die("Connection failed: " . $conn->connect_error);
}

// sql to Insert record table
$sql = "INSERT INTO tblpeople (LNAME, FNAME, ADDRESS)
VALUES ('Villanueva', 'Joken', 'Kabankalan City');";
$sql .= "INSERT INTO tblpeople (LNAME, FNAME, ADDRESS)
VALUES ('Batuto', 'Erick Jason', 'Cebu City');";
$sql .= "INSERT INTO tblpeople (LNAME, FNAME, ADDRESS)
VALUES ('Drapite', 'Bryan', 'Kabankalan City');";

if ($conn->multi_query($sql) === TRUE) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}

$conn->close();
?>

If my mga katanungan PM lg boss.
 
Back
Top Bottom