graham23s Posted January 1, 2008 Share Posted January 1, 2008 Hi Guys, i was wondering if it was possible to position where the: fwrite($file, "<b>Time:</b> $time<br />"); writes to, i have started a table and wanted the fwrite to write new <td> afte this: <table width="100%" border="1" bordercolor="#000000" cellpadding="0" cellspacing="0" /> <tr> <th align="center">Date</th><th align="center">IP</th><th align="center">Came From</th> </tr> so fwrite would write a new entry over and over keeping in line with the table, is this possible at all? thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/83975-solved-positioning-where-to-write/ Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 try reading this: http://www.sitecritic.net/articleDetail.php?id=188 Quote Link to comment https://forums.phpfreaks.com/topic/83975-solved-positioning-where-to-write/#findComment-427330 Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 try this too: TEXT FILE NAMED html_parse_4_links.txt: what the heck <div id='somediv'>im ready for a big glass of coke</div> blah blah blah PHP FILE NAMED html_parse_4_links.php: <html> <head> <style type="text/css"> #editbox { width:500px; height:200px; } </style> </head> <body> <?php if ($_GET['editbox'] != ""){ //if the editbox has anything in it $filename = 'html_parse_4_links.txt'; //this is the file to write to $edit = $_GET['editbox']; //this is the contents of the editbox $before = $_GET['before']; $after = $_GET['after']; $somecontent = urldecode($before); $somecontent.= "<div id='somediv'>"; $somecontent.= $edit; $somecontent.= "</div>"; $somecontent.= urldecode($after); // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In the example, they were opening $filename in append mode "a", but here we are overwriting the file in mode "w". //"a" mode might be pretty cool for a appending a blog with a user comment... if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } }else{ $url = "html_parse_4_links.txt"; $input = @file_get_contents($url) or die('Could not access file: $url'); $regexp = "(.*)<div id='somediv'>(.*)<\/div>(.*)"; if(preg_match_all("/$regexp/si", $input, $matches)) { $beforeEdit = urlencode($matches[1][0]); $string = $matches[2][0]; $theEdit = htmlentities($string); $afterEdit = urlencode($matches[3][0]); echo "<form action='html_parse_4_links.php' method='get'> <input type='text' name='editbox' id='editbox' value='$theEdit'></input> <input type='hidden' name='before' value='$beforeEdit'></input> <input type='hidden' name='after' value='$afterEdit'></input> <input type='submit' value='Save Back 2 File' /> </form>"; } } ?> </body> </html> All you would have to do is modify the code slightly. Quote Link to comment https://forums.phpfreaks.com/topic/83975-solved-positioning-where-to-write/#findComment-427334 Share on other sites More sharing options...
graham23s Posted January 1, 2008 Author Share Posted January 1, 2008 Thanks mate managed to get it from that:) thanks again Graham Quote Link to comment https://forums.phpfreaks.com/topic/83975-solved-positioning-where-to-write/#findComment-427431 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.