Goldi90 Posted January 17, 2011 Share Posted January 17, 2011 Hi, how to make this form + php to make it work this way from the drop-down box choose the database title, or ID, and then the form in which I write some content will be added to the database that matches the title or ID that is sometimes so as not to invade a mistake and content that I type is not added to another title or ID I created something like this: <?php $db = new mysqli('localhost','xxxxx','xxxx','xxxx'); mysqli_query($db,'SET NAMES `utf8`'); $sqlnowe = mysqli_query($db,'SELECT * FROM `cc` ORDER BY `id` DESC '); ?> <form action="formu.php" method="post"> <select name="tytul"> <?php while ($rownowe = mysqli_fetch_array($sqlnowe)) { ?> <option><? echo $rownowe['tytul']; ?></option><?php };?> </select> opismax:<br /> <input type="text" name="opismax" /><br /> <textarea name="opismax" cols="50" rows="10">Proszę, wpisz tutaj jakiś komentarz...</textarea> <input type="submit" value="dodaj" /> </form> <?php // odbieramy dane z formularza $tytul = $_POST['tytul']; $opismax = $_POST['opismax']; if($tytul and $opismax) { // dodajemy rekord do bazy $ins = mysqli_query("INSERT tytul='$tytul' INTO publications SET opismax='$opismax'"); if($ins) echo "Good"; else echo "Bad"; } ?> Link to comment https://forums.phpfreaks.com/topic/224708-problem-with-adding-to-the-database/ Share on other sites More sharing options...
Goldi90 Posted January 17, 2011 Author Share Posted January 17, 2011 close Link to comment https://forums.phpfreaks.com/topic/224708-problem-with-adding-to-the-database/#findComment-1160658 Share on other sites More sharing options...
hvandracas Posted January 17, 2011 Share Posted January 17, 2011 "INSERT INTO table_name (field1, field2, ..., fieldn) VALUES ('value1', 'value2', ..., 'valuen')" Link to comment https://forums.phpfreaks.com/topic/224708-problem-with-adding-to-the-database/#findComment-1160659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.