MartinDuricky Posted April 19, 2017 Share Posted April 19, 2017 Hello i made this script (i am still learning php): <?php $subor = @file('recenzie.txt'); $riadkov = sizeof($subor); $pocet = $riadkov/6; for ($i = 0; $i < $pocet; $i++) { ?> <div class="owl-item"> <div class="row flow-offset-1"> <div class="col-xs-12 col-sm-4 col-lg-3 offset-top-0"> <div class="thumbnail thumbnail-mod-1"><img src="images/<?php echo ($subor[$i * 6 + 2]) ?>.png" alt=""> <div class="caption-mod-1"> <h6><?php echo ($subor[$i * 6 + 3]) ?></h6> <h6><?php echo ($subor[$i * 6 + 4]) ?></h6> </div> </div> </div> <div class="col-xs-12 col-sm-8 col-lg-4 text-sm-left offset-top-0"> <p><?php echo ($subor[$i * 6 + 5]) ?></p> </div> <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-lg-5 col-lg-offset-0 text-sm-left"> <blockquote class="quote-1 bg-white"> <div class="media"> <div class="media-left"> <div class="media-body"> <p> <q><?php echo ($subor[$i * 6 + 6]) ?></q> </p> <p> <cite class="text-primary"><?php echo ($subor[$i * 6 + 7]) ?></cite> </p> </div> </div> </blockquote> </div> </div> </div> <?php } ?> Its making review, if you want to create one you have to write "text" in recenzie.txt: flag name adress review someword signature So you have to write into that text file something in this order. So it looks like that f.e : american Matthew LA 585 This is my review Signature My question is: i want to make form where you write that attributes (name,flag,review...) and then when you submit it will edit that text file. So i have to make tables in SQL right? But how to link that table from SQL with that file? Thanks Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 19, 2017 Share Posted April 19, 2017 Sorry - makes no sense. You want a text file from a db table or to a db table? Quote Link to comment Share on other sites More sharing options...
MartinDuricky Posted April 20, 2017 Author Share Posted April 20, 2017 Nope i need to get data from form into text file. I have wrote code that works: <?php $myFile = "pole.txt"; if(isset($_POST['fileWrite']) && !empty($_POST['fileWrite'])) { $fileWrite = $_POST['fileWrite']; } if($fileWrite) { $fh = fopen($myFile, 'a') or die("can't open file"); //Make sure you have permission fwrite($fh, $fileWrite); fclose($fh); exec('/your/command /dev/null 2>/dev/null &'); } ?> this is the form <html> <body> <form id="some" name="someName" method="post" action="skript.php"> <input type="text" id="field1" class="field" value="" name="fileWrite"/> <input type="text" id="field2" class="fieldd" value="" name="fileWrite"/> <input type="submit" value="submit" class="submitClass"/> </form> </body> But i need to get every data from form (field1 and field2) to text file but separately in a new row so the text file would looks like this after form submiting Field1 data Field2 data and so on Quote Link to comment Share on other sites More sharing options...
dkub Posted April 20, 2017 Share Posted April 20, 2017 You have two fields called fileWrite... Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 20, 2017 Share Posted April 20, 2017 Use unique name attributes to get all your inputs and then simply loop thru the contents of your POST array, checking that they are valid for you and then write a line to the file and repeat. You really want to store stuff in meaningless text files and not a db? Quote Link to comment Share on other sites More sharing options...
MartinDuricky Posted April 20, 2017 Author Share Posted April 20, 2017 Cos i have a script that takes that text from txt file and it makes it as review then. Thats why it needs to be in order and in new row. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 20, 2017 Share Posted April 20, 2017 That 'other' script could read a table just as well as a txt file. To each his own (way). Quote Link to comment Share on other sites More sharing options...
MartinDuricky Posted April 20, 2017 Author Share Posted April 20, 2017 yeah i know but i am not so good in php and i am happy that i have made this script so far. So i edited it to take data from both form cells but it is still writing it in the same row Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 20, 2017 Share Posted April 20, 2017 (edited) And have you done any reading on how to solve that problem? Edited April 20, 2017 by ginerjm 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.