Jump to content

tywiggle

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tywiggle's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You are a brilliant programmer. Your new script works like a charm. I have another question. I modified your script trying to get file_put_contents to put the files into sub directories but is not working. Have I made some type of syntax error or is this even possible? file_put_contents($subfolder / $pattern . '.php', ob_get_contents()); Thank you very much. <?php $cxn = mysqli_connect ("localhost", "xxxx", "yyyy"); mysquli_select_db($cxn, "zzzz"); $query = "SELECT pattern, folder, name, url, name1, subfolder (!<--- added this---->) FROM database"; if ($result = mysqli_query($cxn, $query)) { if (mysqli_num_rows($result)) { while ($row = mysqli_fetch_assoc($result)) { ob_start(); extract($row); include "template.php"; file_put_contents($subfolder / $pattern . '.php', ob_get_contents()); ob_end_clean(); } } } ?>
  2. Thank you so much for your expertise and time. I am very willing to learn though a bit overwhelmed. Here is an example (chopped down and now messy) of what my html looks like and what I am attempting to feed the data into. There are a number of items named 'pattern' and I am trying to generate a php page for each one. I have previously been manually entering 'pattern' then saving as 'pattern.php'. With a limited understanding of php/mysql I have attempted to use the script you wrote but it is ending up with blank pages and no data as coded below. <!--my original code--> <?php $cxn=mysqli_connect ("localhost","xxxx","yyyy"); mysqli_select_db($cxn, "zzzz"); $query="Select pattern, folder, name, url, name1 from database where pattern= 'abcdefg'"; $result=mysqli_query($cxn, $query); $row=mysqli_fetch_assoc($result); extract($row); ?> <!-- new and improved code--> <?php $cxn = mysqli_connect ("localhost", "xxxx", "yyyy"); mysquli_select_db($cxn, "zzzz"); $query = "SELECT pattern, folder, name, url, name1 FROM database"; if ($result = mysqli_query($cxn, $query)) { if (mysqli_num_rows($result)) { while ($row = mysqli_fetch_assoc($result)) { ob_start(); foreach (range('folder','name1') as $pos) { echo $row[$pos]; extract($row);<!--I added this and got the very last 'pattern' in the database to display a page--> } file_put_contents($row['pattern'] . '.php', ob_get_contents()); ob_end_clean(); } } } ?> <html> <head> <title><?php echo $pattern; ?> ?></title> <meta name="description" content="<?php echo $pattern; ?>/> <meta name="keywords" content="<?php echo $pattern; ?> " /> <style type="text/css"> </style> </head> <body> <table width="900" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td bgcolor="#FFFFFF" valign="top"> <table cellspacing="0" cellpadding="0" border="0" width="800"> <tr> <td> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr bgcolor="#000033"> <td width="14" nowrap="nowrap" valign="middle"></td> <td height="24" nowrap="nowrap" colspan="12"><a href="http://www.<?php echo $url ?>.com" class="c3"></a> <div class="c6"><span class="c4"><?php echo $name; ?> .com</span>...<span class="c5"><strong><?php echo $name1; ?></strong></span></div> </td> <td nowrap="nowrap" valign="middle"><span class="c5"><strong> <?php $today = date("F j, Y");PRINT "$today"; ?></strong></span></td> </tr> </table> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td height="1" nowrap="nowrap" bgcolor="#FFFFFF" colspan="10" width="100%"></td> </tr> <tr> <td height="7" nowrap="nowrap" bgcolor="#990000" colspan="10" width="100%"></td> </tr> </table> <table cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center" class="c9" width="100%"> <tr> <td width="100%" valign="top"><table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" > <tr> <td height="14" valign="top" bgcolor="#FFFFFF"><span class="c2"> <a href="http://www.<?php echo $url; ?>.com"> <strong><?php echo $name; ?> Home</strong></a> <span class="c7"><strong>>></strong></span> <a href="http://www.<?php echo $url; ?>.com/<?php echo $name1; ?>.php"> <strong>Name 1</strong> <span class="c7"><strong>>></strong></span> <strong>Designs <?php echo $name1; ?> </strong></a> <span class="c7"><strong>>></strong></span> <span class="c12"><strong><?php echo $pattern; ?></strong></span> </span></td> </tr> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="5" bgcolor="#FFFFFF"> <tr> <td align="center"> <img src="http://www.dataprocess.com/name1/<?php echo $folder; ?>/<?php echo $pattern; ?>.jpg" border="0" /> </td> </tr> <tr> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <tr> <td colspan="3" bgcolor="#FFFFFF"> <div class="c6"> <hr width="90%" /> <span class="c11"><?php echo $url; ?>.com Copyright 2005-<?php $today = date("Y");PRINT "$today"; ?> All Rights Reserved </span></div> </td> </tr> </table> </td> </tr> </table> </body> </html>
  3. Brilliant. Thank you very much. I am sure I will appreciate your code even more when I can fully understand it. Perhaps I can trouble you a bit more? When I execute this, I get the appropriate named files saved onto my website. They are all blank as in zero bytes. I assume I need to do something within the object buffer. I do not understand what "$pos" is or what it does in the echo statement. How would I execute the html portion of the page that calls the variables pulled in during the query? Do I extract the $row?
  4. Attempting to create a number of static web pages. Is there a way to automatically add the variable and then auto save the page as 'pattern'.php? Here is the code I have been using: <?php $cxn=mysqli_connect ("localhost", "xxxx", "yyyy"); mysquli_select_db($cxn, "zzzz"); $query="select pattern, a, b, c, d, e from 'database' where pattern='pattern'";(<--this is the variable I need to change automatically) $result=mysqli_query($cxn, $query); $row=mysqli_fetch_assoc($result); extract($row); ?> After 'pattern' is automatically inserted into the code I need to automatically save the page as 'pattern'.php and then move on the the next 'pattern' in the database.
  5. To further clarify: I have 3000 values to plug into the variable named 'pattern'. After the value is plugged in, I need to automatically save the page as 'pattern.php'. Any suggestions? Not to stir the pot, but I really need to make the php pages into HTML. This is for specific SEO purposes where a specific format of HTML is absolutely required. Any suggestions?
  6. Hello, I have a rather basic knowledge of PHP and SQL. I am creating a large number of static web pages. I currently have to change the variable 'pattern' by hand and then save the file manually as 'pattern'. I can easily do a number of pages an hour but it is very tedious. Is there a way to automatically add the variable and then save the page as 'pattern'.php? Here is the code I have been using: <?php $cxn=mysqli_connect ("localhost", "xxxx", "yyyy"); mysquli_select_db($cxn, "zzzz"); $query="select pattern, a, b, c, d, e from 'database' where pattern='pattern'";(<--this is the variable I need to change automatically) $result=mysqli_query($cxn, $query); $row=mysqli_fetch_assoc($result); extract($row); ?> After 'pattern' is automatically inserted into the code I need to automatically save the page as 'pattern'.php and then move on the the next 'pattern' in the database. Another question: Is it possible to automatically convert existing php webpages to HTML pages and erase a date display from the code (the date shows but never changes). I have also been doing this manually and it seems there has to be a better way. Any suggestions or tutorials someone can point me to would be greatly appreciated. Thank you, Ty, the cross-eyed guy with worn out typing fingers.
×
×
  • 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.