Jump to content

This script into table


MartinDuricky

Recommended Posts

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.