Jump to content

ripkjs

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

About ripkjs

  • Birthday 05/20/1984

Contact Methods

  • AIM
    ripkjs

Profile Information

  • Gender
    Male
  • Location
    WI

ripkjs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. After a bit of playing, I found this ghetto way of solving the problem... Might be a better one out there, but if it works, why fix it! <div class="history" style="height: <?php $points = 'BALANCES.HTM'; $getPoints = file_get_contents($points); $countTR = substr_count($getPoints, "<TR"); $h = 2; //Difference in header row $r = 22; //Height of each row $result = ($countTR*$r-$h); echo $result ?> px;">
  2. Yup, I'd like to actually extend that column down, not just have an illusion of it being the same. There's going to be actual content that will be in the orange area that I'd like to have the same height as the table to the left (red). If I don't give the orange a height, it extends down the page 2-3x longer than the red. Which wouldn't be an issue if the red element was always static, but rows will be added and removed over time. Is there a way to use code to get the height of the red, then set that height in the CSS?
  3. I'm looking to change the height of one element to the size of another. Here is a screen shot for a better idea of what I'm talking about. The red element is an include of a table. The height of this element will change depending on the content. Width will always be the same. The orange element is an include of several other various htm files. This will always be much taller than the red element. I need the height of this to extend to the bottom of the light orange area (being the end of the red in the screen shot. For the screen shot's sake I gave the orange element a static height of 500px.) I need the red element and orange element to have the exact same height, while red is dynamically defining this shared height. The overflow of only the orange can scroll. Here is the basic code that is being used. Stripped out the PHP to shorten the example code. Using CSS to format these elements. <body> <div class="virtab"> <div class="banner"> </div> <div class="head"> </div> <div class="body"> <table> <tr> <td> <div class="red"> <?php //***RED ELEMENT***// ?> </div> </td> <td> <div class="orange"> <?php //***ORANGE ELEMENT***// ?> </div> </td> </tr> </table> </div> <div class="foot"> </div> </div> </body>
  4. Looking to grab the contents of a subdir and combine/append the contents of .htm files in that directory, and any new ones added, into one usable string. The .htm files will always be named with the 6 digit MMDDYY.htm, and maximum of only one per day (3-4per week in total). So I think that would eliminate the need to check the file date. I'd like to display the contents of the newest one on top, and descend as the dates get older. With scandir() I can get these files in an array (and in the correct order), but the first two keys are being taken up with "." and "..", and going beyond that, I'm not sure how to get the contents of the items in the array to display.
  5. Well, what I do understand of this so far is: $points = "points.html"; //Defining the file to be parsed. $getPoints = file_get_contents($points); //Grabbing the contents of that file as a string. function odd_replace($matches) { //creating a function with the name odd_replace, $matches being the arguments. static $count = 0; //Defining the variable as 0, and making it static (which i think means each time this function is called, that it will remain 0) if ($count % 2 == 0) { //Checks $count to see if the number is even. $matches[1] = '<tr class="row1">'; //Sets the 1 key in the $matches array to the string in single quotes if $count is even? (guess) } else { $matches[1] = '<tr class="row2">'; //Same as above only if it is odd. } $count++; //increments $count by one. $i = 1; //setting $i to 1 for use in the preg_replace to give each <td> its own unique number. $matches[2] = preg_replace('/<td>(.+?)<\/td>/ise', "'<td class=\"c' . \$i++ . '\">' . '\\1' . '</td>'", $matches[2]); /* this is where things get a tad fuzzy. I don't quite understand most of this, mostly all the added slashes and other toys. I know the first parameter is looking for <td>. Single quotes around it because it is a string? Not sure why the first forward slash is there, though I'm assuming that it is defining the < as being literal, and not 'less than'. (.+?) I'm not sure, though guessing its some sort of wildcard. Assuming the next backslash after the > is again saying that its literal, and not 'greater than'. /ise, no idea. second parameter being what its replacing the first parameter with. Double quotes around all of it because you're using delimiters in the string. Backslash double quote again for literal. " . " is the delimiter, combining it all. \$i++ is taking $i and incrementing it by one each time the function is called. '\\1', not sure. closing the tag, then the next parameter being the source for the replacements. */ return $matches[1] . $matches[2] . $matches[3]; //Not sure. } $getPoints = preg_replace_callback("/(<tr>)(.+?)(<\/tr>)/is", "odd_replace", $getPoints); //replacing <tr> with the results from the odd_replace function, in $getpoints. echo $getPoints; //echos the string. So I guess to make a short answer long, I don't really understand why it was messing with the image variables I apologize if this was painful to read for anyone. I'm only about 4-5 days into PHP (or any scripting/coding outside html).
  6. It was after. But I figured it out! I had it all sandwiched between your funtion and your preg_replace_callback. Whew. Perfect! Everything works like a charm. Again, many thanks Dark.
  7. I've been trying to follow along using the php.net reference guide. So I have an understanding of how it works, I just wouldn't be able to actually write it.. (yet? ) Have been learning lots, this project seems to be a good place to start trying to understand scripting. Doesn't seem to be too complex yet.
  8. Though now my "images/image.png" is getting changed. any Idea why this is happening? <td class="c1"><img src=\"images/image.png\" /></td> This is how the img is being displayed. Changing any RCt to the image tag. $rcT = '<img src="images/image.png" />'; $getPoints = preg_replace("/RCt/", $rcT, $getPoints);
  9. Win. You are a godsend, Dark. I can't Thank you enough!
  10. yes, every <tr> </tr>will have only 8 <td> in between, never any more or less.
  11. I have a file that is exported by an application as an .html with tables. In another post I had made here, DarkWater showed me the way to get the script to replace every other instance of <tr> with a <tr class="x">. Here is that script: <?php $points = "points.html"; $getPoints = file_get_contents($points); function odd_replace($matches) { static $count = 0; if ($count % 2 == 0) { //even $count++; return '<tr class="row1">'; } else { $count++; return '<tr class="row2">'; } } $getPoints = preg_replace_callback("/<tr>/i", "odd_replace", $getPoints); echo $getPoints; Now on the same Idea of that script, is there a way to replace the table columns? Example of the htm prior to changes: <TR> <TD>text</TD> <TD>text</TD> <TD>text</TD> <TD>text</TD> <TD>text</TD> <TD>text</TD> <TD>text</TD> <TD>text</TD> </TR> And would like to change those to: <TR> <TD class="c1">text</TD> <TD class="c2">text</TD> <TD class="c3">text</TD> <TD class="c4">text</TD> <TD class="c5">text</TD> <TD class="c6">text</TD> <TD class="c7">text</TD> <TD class="c8">text</TD> </TR> So there will always be 8 <td> opener tags that will need their own unique class="x" between each <tr> and </tr>. And need to have it repeat this multiple times within the html. Sorry for my ignorance, but you all have been a great help so far, and this project is my first real scripting 'lesson'. I appreciate all the patience and guidance!
  12. Originally in the code I was using the double quotes around the image tag, but when I rewrote the variable here I used single quotes. Stupid mistake, and you all got to witness it! Grats on your 4k post also, Little Guy!
  13. I got it working, i think i was using double quotes: $clP = "<img src="imagelink.png" />"; Brain fart... Works okay now with single quotes. We won't tell anyone about this mmk!?
×
×
  • 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.