John H Posted August 21, 2010 Share Posted August 21, 2010 What I am working on is a background to a user input comment -- essentially a framed box around the comment. For some reason I cannot fathom but which is probably simple, I can't get the image height variable, (set by the length of the comment) to be seen by the code outputting the framed box. So here's what I got: To set the image position and height variables I put this code inside of a while loop, since there are multiple comments in the DB: //Looks at the comment in the DB //Calculates the number of lines based on 75 characters per line $line_count = ceil(strlen($row3['comment'] /75)); //This sets the position of the username who posted the comment $username_pos = ($text_pos + ($line_count * 33)) . ".00pt"; //Sets the initial starting position of the framed box on the page $box_pos = $text_pos - 42.00 . ".00pt"; //Sets the height of the framed box $box_ht = $username_pos + 50 . ".00pt"; //Outputs the framed box echo "<img src='images/blue table.gif' style='position:absolute; left:140.00pt; top:$box_pos'; height:$box_ht'; width = 570.00pt; z-index:-1 class='cc01'>"; There is also code outputting the comment and username which seems to work just fine. The result is a pretty box framing the comment, but the outputted image always ends up with the same height, which obviously doesn't work because each comment in the DB can have a different number of lines and would need a different size box. Just to be clear, the source image is much larger than what can be produced by this code. If anyone has any suggestions, I'd really appreciate it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/211336-dynamic-image-height/ Share on other sites More sharing options...
RussellReal Posted August 21, 2010 Share Posted August 21, 2010 might I ask even why you'd want to do this this way? why not just make the borders or w.e u r tryna do with css.. nothing needs to be dynamic here.. it just needs to be positioned correctly with css Quote Link to comment https://forums.phpfreaks.com/topic/211336-dynamic-image-height/#findComment-1101956 Share on other sites More sharing options...
John H Posted August 21, 2010 Author Share Posted August 21, 2010 Thanks for writing. The reason I didn't do this with CSS is because you can't use variables with CSS. It is my understanding that they are considering allowing variables in future versions, but as far as I know, that hasn't happened yet. The reason I need to use a variable is because the height of the image -- essentially a box that frames the comment--would be defined by the length of the comment. Any given comment a user submits could output as 1,2,3 lines (or more) on the web page, depending on the length of the comment. So, the box image height has to be a variable based on the comment length. Does that make any sense? Quote Link to comment https://forums.phpfreaks.com/topic/211336-dynamic-image-height/#findComment-1101960 Share on other sites More sharing options...
RussellReal Posted August 21, 2010 Share Posted August 21, 2010 yes.. so why not have 3 images.. top image.. middle image.. bottom image (assuming all the comments are the same width..) then all you do is something like this <div class="comment"> <div class="comment-top"> </div> <div class="comment-middle"> comment goes here! </div> <div class="comment-bottom"> </div> </div> and give the images accordingly to the divs Quote Link to comment https://forums.phpfreaks.com/topic/211336-dynamic-image-height/#findComment-1101968 Share on other sites More sharing options...
John H Posted August 21, 2010 Author Share Posted August 21, 2010 Oh, I see what you are saying. I hadn't looked at it that way. I think that will work. Thank you. I'll give it a try tomorrow. Quote Link to comment https://forums.phpfreaks.com/topic/211336-dynamic-image-height/#findComment-1101996 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.