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"; } ?> Quote Link to comment Share on other sites More sharing options...
Goldi90 Posted January 17, 2011 Author Share Posted January 17, 2011 close Quote Link to comment 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')" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.