Jump to content

axtg86

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

axtg86's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So here's the deal: I have a question and answer table. The question table specifies whether a question is formulated positively or negatively (qsReversed is 0 or 1). Based on this answer I want to sum the answer values accordingly. If it is not reversed 5=5, if it is reversed 5 should be 1, 4->2, etc. I know exactly how to recode variables in SPSS, but haven't been able to do so using SQL. Closest that I have gotten (no error, no results) is Thanks for any input anyone might have!
  2. There you go... Thanks for the quick reply.. Almost embarassing really
  3. This is going to be a quick one. I figured it should work, but it doesn't so I probably am missing out on something I don't know about getting this function to work (how hard can it be?) $emptyfile = file_get_contents("empty.inc.php"); foreach ($_POST['value'] as $key => $value) { $newfile = str_replace($key, $value, $emptyfile); } print_r($newfile); The empty.inc.php file contains variables with numbered values which need to be replaced with what has been posted. So: $var1 = "1"; $var2 = "2"; $var3 = "3"; I expected the function above to replace 1, 2 and 3 with what has been posted in the $_POST['value']. What am I missing? Thanks!
  4. That is going to be worth a try tomorrow morning. To prevent myself of skipping sleep I've set my PC to auto-shutdown at 2.10am. Which is in 9 minutes . I'll try the latest suggestion and possible other thoughts tomorrow and will report back (either solved or with follow-up). Thanks for your time (so far )!
  5. Short: no it doesn't... I don't get to use classes much (just db actions), but I'm having the most trouble with "instantiate the class in each template". Put: class content{ public function getContent(){ $filestream = @fopen("content.php", "r"); $filecontent = @fread($filestream, @filesize("content.php")); echo $filecontent; } } in a separate file and call $content->getContent(); in each template file?
  6. Hi again, It certainly makes sense, but I can't see how the content of the template file that is included can then run code on its own. But that might have something to do with me never having tried it... So: index.php // Part 1 function getContent() { $filestream = @fopen("content.php", "r"); $filecontent = @fread($filestream, @filesize("content.php")); echo $filecontent; } // Part 2 $result = "SELECT * FROM `pages` WHERE `page` = '".$_GET['page']; // As illustration $row = mysql_fetch_row($result); include_once("/templates/".$row['template'].".php"); template.php ... <body> <p><? getContent; ?></p> ... I'll give it a try, but it appears kind of nested to me .. Thanks!
  7. Hi p2grace, I admit I had difficulties formulating the problem. I think I could have better used the term "merge" in there. I have two files (template file and content file). The content file does not contain any layout mark-up, just content. Based on the specified template in the DB for that content file (specified by $_GET['page'] the appropriate template file has to be applied to it. Causing the two to merge. Much like e.g. Drupal, Joomla where you have a template file that can be applied to certain content. Except now not using a database that holds the content, but an actual file. Does that clarify things? Thanks for your reply!
  8. Hi, A newly formulated question which hopefully someone can point me in the right direction for. This is what I'd like to accomplish: I've got a .htaccess file that rewrites any *.html file to index.php?page=*. So when page welcome.html is requested it gets rerouted to index.php?page=welcome. This works fine, but the next step is causing me trouble. Note that content are saved in separate text files. I'm running a query (WHERE page=$_GET['page']) to select $row['template'] for the requested file. In the templates directory such a template exists (/templates/$row['template'].php) which I now want to apply to the contents (which can include PHP as well) of the designated page (/contents/$_GET['page'].php). Unfortunately I haven't been able to find a solution for this without e.g. using a header(location) function (I'd like to keep the address in the address bar in tact) or frame. A CMS such as Joomla is able to do this. But that system uses a database to store contents. How could I proceed? Thank you! -- P.s.: I've had a topic before, but my vision has changed in the mean time. I tried closing it, but no luck. Since it is currently at page 10+ I don't consider it disturbing.
  9. Hi, Thank you for your suggestions. I'll surely try to search the forums for "template routing" and such terms. Since you indicated your personal favor I'd like to ask you for your preference when actually using two different HTML files. I'm considering this, since in the end I might use the same technique for different templates as well (based on e.g. depth). Thanks! Xander. P.s.: Hello in Dutch is indeed Hallo .
  10. Hi all, I'd like to ask for your input and ideas on the following: I've got a back-end system managing a websites content. It has a default index.php file with variable holders such as $title, $content, etc which are set by an included file depending on the ?page= querystring. So if ?page=home then the include looks up the DB and fills the variables. All fine, but now I'd like to use different "templates" for both an English variant and Dutch variant. Perhaps even more are to be added later. How can I still use one index.php with the current include feature but have different templates applied to it based on a database variable for a certain page? Imagine the page home-nl and home-uk being requested (index.php?page=home-nl or index.php?page=home-uk). The include file finds for home-nl $row['variant']=nl. In this case the template applied to the index.php should be nl(.html) with Dutch texts, a Dutch menu, etc but still have $title and $content inserted. I've tried this for index.php (see below), but stream_get_contents() doesn't parse (of course) PHP. I realize this is a bit "out there", and it might never be answered. But never hurts trying, right ? Thanks! <?php require_once('./lib/contentfill.php'); if ($stream = fopen("./lib/templates/".$row['variant']."/index.php", 'r')) { $stream = stream_get_contents($stream); $tag = array($content, $title); $data = array($row['content'], $row['title']); $contents = str_replace($tag, $data, $stream); echo $contents; } ?>
  11. Hi, I've been looking at some classes besides the default PHP zip class, but haven't been able so far to accomplish zipping a directory located on another server using FTP on the fly. I've got my scripts hosted on one PHP enabled website and my images uploaded at a file storage server which doesn't allow to run PHP. Is there a way (at all before looking any further) to add files located on another server to a zip by using FTP? Thanks!
  12. Hi, I've been reading through the Yahoo speed guidelines, and wanted to do something with the CDN suggestion. Meaning that I want to put my static content (images) on a subdomain. I'm now wondering how I can do this through PHP. I can of course change all my image src locations to <img src="http://cdn.mydomain.com/img/xx" alt=".."/>, but I rather have a PHP script get the images by having something like <img src="cdn.php?file=img.png" alt=".."/> which then loads the image from a server I specified in the cdn.php file (and thus can easily change). It will need to output a header() tag to have the browser recognize the image itself is coming from an external server. I've been playing with a GD library to try to get this done, but I am starting to think I'm making way too much trouble of this. So I figured I would be best of here to check for other opinions . Cheers!
  13. Hi all, It has been one of those days. Looking at two lines of code all day, not being able to solve the issue. Here is what I'd like to do. Let's say I have three pages (simplified example). content.php <? echo "hello world"; ?> fillcontent.php function getContent($page) { $filestream = @fopen("./content/".$page.".php", "r"); $filecontent = @fread($filestream, @filesize("./content/".$page.".php")); $brace_o = "("; // Convert to eval() friendly character $brace_c = ")"; $semi = ";"; $ques="?"; $php_open="<${ques}php"; $php_close="${ques}>"; eval("$php_closestrtoupper${brace_o}$filecontent${brace_c}${semi}$php_open"); // = eval("?>strtoupper($filecontent);<?"); // I'm closing php tag first, because $filecontent already contains these (prevent repetition) } index.php <? getContent('content'); ?> But this throws me the following error: I have no clue what is causing this. So any new directions are much appreciated! For those curious (might help): I'd like to include user generated pages (which might include PHP) into a template file and instead of the strtoupper() mentioned above I'd like to include a markdown() function. Making it possible for users to use Wiki mark-up (== header ==). Best regards!
×
×
  • 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.