01-29-2009, 03:33 PM
|
#3 (permalink)
|
|
The Contributor
Join Date: Nov 2007
Posts: 41
Thanks: 24
|
Sorry for the confusion but this is what I want to accomplish:
- Create a front-end to edit the array values in myData.php
so far, i got the data to display in the front end with this code:
edit.php
PHP Code:
<?php require_once('myData.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Editor</title> <style> div#container{width: 960px; font: 12px tahoma; line-height: 20px; } div#container label{ clear: both; display: block; float: left; width: 80px; text-align: right; margin-right: 10px; } div#container input{ float: left; width: 500px; } div#container p.spacer{ display: block; height: 20px; clear: both; } </style> </head>
<body> <div id="container"> <h3>Editor</h3> <form id="form2" name="form2" method="post" action=""> <?php $step = 1; if($limitdata) {$i = 0;} foreach ($data as $datas) { if($limitdata) { if($i>=$limitdata) continue; }
$dataslink = $datas['theURL']; $datastitle = $datas['title']; $datassometext = $datas['someText']; $datasmoretext = preg_replace("/<img.+?>/", "", $datas['moreText']); $datasthumb = $dataimagefolder.$datas['thumbnail']; $datacontent = "\n"; $datacontent .= "<label>Link ".$step."</label><input type=\"text\" name=\"link".$step."\" value=\"".$dataslink."\" />\n"; $datacontent .= "<label>Title ".$step."</label><input type=\"text\" name=\"title1\" value=\"".$datastitle."\" />"; $datacontent .= "<label>Some Text ".$step."</label><input type=\"text\" name=\"subtitle1\" value=\"".$datassometext."\" />"; $datacontent .= "<label>More Text ".$step."</label><input type=\"text\" name=\"teaser1\" value=\"".$datasmoretext."\" />"; $datacontent .= "<label>Thumbnail ".$step."</label><input type=\"text\" name=\"image1\" value=\"".$datasthumb."\" />"; $datacontent .= "<p class=\"spacer\"></p> ";
echo $datacontent; if($limitdata) {$i++;} $step++; }
?>
</form> <p> </p> </div> </body> </html>
myData.php
PHP Code:
<?php $data = array( array( "theURL" => "http://www.google.com", "title" => "Google", "someText" => "Google Search Engine", "moreText" => "Google Search Engine. Find whatever you want on the web.", "thumbnail" => "tn_google.jpg" ),
array( "theURL" => "http://www.yahoo.com", "title" => "Yahoo", "someText" => "Yahoo Search Engine", "moreText" => "Yahoo Search Engine. Find whatever you want on the web.", "thumbnail" => "tn_yahoo.jpg" ),
array( "theURL" => "http://www.msn.com", "title" => "MSN", "someText" => "MSN Search Engine", "moreText" => "MSN Search Engine. Find whatever you want on the web.", "thumbnail" => "tn_msn.jpg" ), ); ?>
I know I can just create another file to save the POST values and overwrite the myData.php file but I just want to know if there was a better way of doing this (without involving a database).
__________________
"Things you can get access to, you should never memorize." -Albert Einstein
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
|
|
|
|