Schlo_50 Posted May 28, 2008 Share Posted May 28, 2008 Hi guys, I have a list stored as a .DAT file. This file gets updated and added with new data fairly regulary. The rows of data can be editted in the backend, but when any row of data is editted that whole row is then sent to the bottom of the file and I need it to stay where it is, in order. I only want the newest row added to be at the bottom of the .DAT file. This is the edit script, if this helps? I just need some way of not having a row that is editted be moved to the bottom of the file. The structure of the .DAT file is: product|pid|category|reference|price|description|status|available|rating|offertext|pend|poster|ordernumber| $pid = $_POST['pid']; $Lines = file("data/threads.DAT"); foreach($Lines as $Key => $Val) { $Data[$Key] = explode("|", $Val); if ( trim($Data[$Key][1]) == $pid ) { $product = $_POST['product']; $category = $_POST['category']; $reference = $_POST['reference']; $price = $_POST['price']; $description = str_replace("\n", "[break]", $_POST['description']); $status = $_POST['status']; $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $poster = $_SESSION['c4username']; if($verify == "on" && $_SESSION['c4perms'] != "admin"){ $pend = "pending"; } else { $pend = "verified"; } $rating = "sale"; $offertext = $_POST['offertext']; unset($Lines[$Key]); $fp = fopen("data/threads.DAT", "w"); $fw = fwrite($fp, implode('', $Lines)); fclose($fp); $content = "$product|$pid|$category|$reference|$price|$description|$status|$available|$rating|$offertext|$pend|$poster|$ordernumber|\n"; $content = stripslashes($content); $fp = fopen("data/threads.DAT", "a"); fwrite($fp, $content); fclose($fp); } } Can anyone help? Link to comment https://forums.phpfreaks.com/topic/107641-editting-file/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.