gecekule Posted November 10, 2012 Share Posted November 10, 2012 Hello, I'm sorry, my English is bad I'm beginner include "./includes/config.php"; sql connection to the existing The help of two-table query? Best Regards Thanks Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/ Share on other sites More sharing options...
smoseley Posted November 10, 2012 Share Posted November 10, 2012 Your table1 design is incorrect. It should look more like this: id table2_id amount 5 1 12 5 3 3 5 5 7 Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391503 Share on other sites More sharing options...
gecekule Posted November 10, 2012 Author Share Posted November 10, 2012 Thank you for your answer Tables of have to be like in the picture Continues to Tables This picture is an example The first table resource based, I have to make query, but how? Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391517 Share on other sites More sharing options...
gecekule Posted November 10, 2012 Author Share Posted November 10, 2012 OR How do I write to the database? Insert multi row? id table2_id amount 5 1 12 5 3 3 5 5 7 source: $id=5; name="produc_id[]" name="amount[]" implode(", ", $_REQUEST['produc_id'] // 2, 4, 6, 7 like implode(", ", $_REQUEST['amount'] // 5, 8, 12, 20 like Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391621 Share on other sites More sharing options...
gecekule Posted November 11, 2012 Author Share Posted November 11, 2012 Helo, Here is the error? $query = 'INSERT INTO table_name (`id`, `receiver_id`, `receiver_adet`) VALUES (5, (' .implode('), (', $_REQUEST['secilenreceivermarka_id']). .implode(')', '(', $_REQUEST['secilen_receiver_sayisi']) . '))'; $result = mysql_query($query) or die('Could not execute INSERT query'); Thanks Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391631 Share on other sites More sharing options...
Jessica Posted November 11, 2012 Share Posted November 11, 2012 You really should fix the structure of the tables. Google normalization Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391635 Share on other sites More sharing options...
gecekule Posted November 11, 2012 Author Share Posted November 11, 2012 Change yes, This code does not work for the new table. I wonder what this error code? $query = 'INSERT INTO table_name (`id`, `receiver_id`, `receiver_adet`) VALUES (5, (' .implode('), (', $_REQUEST['secilenreceivermarka_id']). .implode(')', '(', $_REQUEST['secilen_receiver_sayisi']) . '))'; $result = mysql_query($query) or die('Could not execute INSERT query'); Thanks Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391664 Share on other sites More sharing options...
jazzman1 Posted November 11, 2012 Share Posted November 11, 2012 Could you echoing out your $query before to send it to the database and post out the result, please. I suspect that you have a syntax error(s). Also, instead of die('Could not execute INSERT query') use die(mysql_error()). Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391679 Share on other sites More sharing options...
gecekule Posted November 11, 2012 Author Share Posted November 11, 2012 Parse error: syntax error, unexpected '.' in D:\www\8.php on line 77 I guess the problem here: .implode('), (', $_REQUEST Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1391735 Share on other sites More sharing options...
jazzman1 Posted November 14, 2012 Share Posted November 14, 2012 So, your problem is obvious! Link to comment https://forums.phpfreaks.com/topic/270537-the-help-of-two-table-query/#findComment-1392161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.