PHP - Images/text Not Scaling To Screen Width
Ok, first off CSS is definitely not my strong suit so bear with me here. This is my code:
<style media="screen" type="text/css"> /* <!-- */ .clear{ clear:both; } #grid{ width: 100%; } .grid-element{ width:33%; float:left; } a.clickable-div { display: block; height: 100%; width: 100%; text-decoration: none; } .img { height:auto; width:inherit; max-height:100%; max-width:100%; } .button { color: #900; font-weight: bold; font-size: 150%; text-transform: uppercase; display: block; width: 50%; } /* --> */ </style> <div id="grid"><div class="grid-element" align="center"> <img src="images/light_offline.png" class="img"> <p><h1>Hue Lamp 1 </h1></div><div class="grid-element" align="center"> <a href="action.php?light=2&state=false"> <img src="images/light_off.png" class="img"></a> <p><h1>Hue Lamp 2 </h1></div><div class="grid-element" align="center"> <a href="action.php?light=3&state=false"> <img src="images/light_off.png" class="img"></a> <p><h1>Hue Lamp 3 </h1></div></div><p> <div align="center"> <form method="POST" action="action.php"> <input type="hidden" name="scene" value="02b12e930-off-0"> <input type="submit" value="Scene 1" class="button"> </form> <p><form method="POST" action="action.php"> <input type="hidden" name="off"> <input type="submit" value="All Off" class="button"> </form> </div>This is the browser output. A couple things are wrong: 1. Why aren't the images scaling so they are all the same size? I assigned the same CSS class to each of the images but they are all appearing differently. The original images are all the same size. 2. Why are my buttons in the far right corner? I want to have them centered below the images so as to prevent the horizontal scroll bar, which I hate. Attached Files output.png 232.09KB 0 downloads Similar TutorialsIm using this code to call all the images in a folder: Code: [Select] $handle = opendir(dirname(realpath(__FILE__)).'/images/'); while($file = readdir($handle)){ if($file !== '.' && $file !== '..'){ echo '<img src="admin/img/uploads/'.$file.'" border="0" />'; } } My html says the images are present but they aren't visable on screen: Code: [Select] <div id="contentbody"> <img src="admin/img/uploads/send-button-sprite copy.png" border="0" /> <img src="admin/img/uploads/test" border="0" /> <img src="admin/img/uploads/counter.jpg" border="0" /> <img src="admin/img/uploads/send-button-sprite.png" border="0" /> </div> Any help is much appreciated! I'm have trouble getting my script to show images in a table across the screen. I want to show the picture and have the description shown below it. Right now it shows it in a column with the name next to it. Any help would be greatly appreciated. Thanks in advance. Below is the script. <?php include 'config1.php'; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year = '1954'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; echo "<table>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div> <a><img src="<?php echo $tn; ?>"</a><a><?php echo $title; ?></a></div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> I need to set the width and let height adjust to the proportions of width. Can someone please help me with this? I understand that $canvas_height should be 160, but then the image will crop to whichever side is greatest not by the width only. Code: [Select] <?php $img = "image.jpg"; $canvas_width = 160; $canvas_height = 0; list($img_width, $img_height) = getimagesize($img); $ratio_orig = $img_width / $img_height; if($canvas_width / $canvas_height > $ratio_orig) { $canvas_width = $canvas_height * $ratio_orig; } else { $canvas_height = $canvas_width / $ratio_orig; } $original = imagecreatefromjpeg($img); $canvas = imagecreatetruecolor($canvas_width, $canvas_height); imagecopyresampled($canvas, $original, 0, 0, 0, 0, $canvas_width, $canvas_height, $img_width, $img_height); $dest = "medium/image.jpg"; imagejpeg($canvas, $dest, 100); ?> Hi Im working on a market place style website. the framework im using is called elgg. it uses an algoritm to find the right approximate width and height of an image thats being uploaded. but on my site, all heights and widths must be the same. this is difficult because some pictures have much greater width than height and some have much greater height. so whats the best algoritm to use to make an accurate thumbnail of all images uploaded? Thanks Hello, I have a long list of webpage addresses like this which extends below the fold / the bottom of a user's screen: Webpage 1 Webpage 2 Webpage 3 Webpage 4 Webpage 5 Webpage 6 Webpage 7 Webpage 8 Webpage 9 Webpage 10 Webpage 11 etc... I want to take this long list of words and split them into columns so that the reader never has to scroll down. Please can you tell me the best way of going about this? (should I just design for a specific screen resolution? - if so which screen resolution should I design for?). Many thanks, Stu Hi there I have an image in a directory, that I need to resize on the fly but has to be a background in a div with a max width. I have to determine the correct height according to this max width. So I sucessfully I have accomplished this, but its not scaling its jsut giving me the top left corner according to my height width properties. Here is my working code to grab height and width: Code: [Select] $img_path = $CONFIG["full_url"].$CONFIG["upload_folder"].ReadDB($News["image"]); $max_width = 110; $max_height = 400; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $mywidth = intval($ratio*$width); $myheight = intval($ratio*$height); Now using those I need to resize the image proper to get it centered up. I dont really want to save the file I just want to display it. Is this possible? My attempts have garnered a bunch of crazy characters on screen and not an image. Here is the code I added to the end: Code: [Select] // Resample $image_p = imagecreatetruecolor($mywidth, $myheight); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $mywidth, $myheight, $width, $height); // Output imagejpeg($image_p, null, 100); Then Im using it on the page like so: Code: [Select] <div class="theimg" style="display:block; width:<?php echo $mywidth;?>px; height:<?php echo $myheight;?>px; background-image:url(<?php echo $image_p; ?>); background-repeat: no-repeat;"/> </div> and heres what I get :/ What am I doing wrong?? The image is not displaying inside its rounded corner border and we have crazy crap on top. Thanks in advance When i upload photos and the name of the photo i would like to be able to overlay a portion of the original photo with another image already in the site directory, and also add the photos name over the top of the overlayed image, i may have explained this in a confusing way so i have attached an example. Is this something that can be done using something like GD or imagick, if so could someone please give me a good place to start. Hi All, i am trying to Generate a image dynamically. Up to here i am able to do it . But when i give any echo statement with this its not working.. Here is my code pls help me in this <?php // Create a 55x30 image $im = imagecreatetruecolor(79, 79); $unknow = imagecolorallocate($im, 0, 255, 255); $white = imagecolorallocate($im, 255, 255, 255); // Draw a white rectangle imagefilledrectangle($im, 4, 4, 75, 25, $unknow); imagefilledrectangle($im, 4, 29, 75, 50, $unknow); imagefilledrectangle($im, 4, 54, 75, 75, $unknow); // Save the image echo 'hi hello'; header("Content-type: image/png"); //imagepng($im, './imagefilledrectangle.png'); imagepng($im); imagedestroy($im); ?> Thanks in advance. So on a cloud computing platform such as AWS, how would one keep the /html folder in Apache identical?
I can FTP into one "instance" and modify code easily enough, but how would I push reversions to multiple servers at once?
It seems like such a simple question, but the answer eludes me.
Edited by arbitrageur, 20 November 2014 - 04:43 PM. hi, how is everybody doing? i hope well, i have a problem with some php code. i am trying to split some text in two parts once they have been split, they are display, but sometimes the php code break the source code of the page such as images and instead of the image i get the source code like this Quote add-plugins-paintnet-1.2-800x800 3857cff9733e6a.jpg" style="border-width: 1px; border-color: #000000; border-style: solid; margin: 4px auto 5px; display: block;" /> i have tried for about 2 days now to fix it and i haven't been able to, so any help or guidence would be greatly appreciated. this is the code that i am currently using, i have tried to change the variable in the $findTag but nothing seems to work Code: [Select] <? php $article =$this->article_>text; $countchars=strlen($article); $divide=$countchars/2; $firstpart=substr($article,0,$divide); $secondpart=substr($article,$divide); //i keep changing the <p /> variable to <img /> and $image and many others but nothing seems to work $findTag = strpos($secondpart, "<p /> "); $var = $divide + $findTag $firstpart = substr($article, 0, $var); $secondpart = substr($article, $var); ?> thanks When I asked about adding a watermark to a video, this was suggested: "when scaling it, I'd do h/5:w/5 (of the source video), then position would be w/20 (5% from the left) and h-h/3 (75% of the way down) When I asked about adding a watermark to a video, this was suggested: "when scaling it, I'd do h/5:w/5 (of the source video), then position would be w/20 (5% from the left) and h-h/3 (75% of the way down)" I'd like to try that, but I don't know how to integrate that into my existing working code: $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=426:-2, overlay=10:10, " -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_240.' 2>&1'; I've looked at the ffmpeg documentation, but need additional assistance. any help is appreciated
I'm trying to make my text and images into clickable links. The images and text are in a database so its getting really tricky for me since I'm new to PHP. I've tried many different ways without success. Here is a snippet of the code I'm working with. As you can see, I'm also working with an image re-sizer. I would really like to make those images and text clickable links(i.e. Title). Any help is appreciated! if ($res) { while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) { $detail = $newArray['id']; $photo = $newArray['photo']; $id = $newArray['title']; $price = $newArray['price']; list($width) = getimagesize($photo); // set the maximum width of the image here $maxWidth = 100; if ($width > $maxWidth) echo "<p><img alt=\"Image\" width=\"$maxWidth\" src=\"$photo\" />"; echo "Title:".$id." Price:".$price."<br/"; the idea on what im doing is like a converter, like showing what your name would look like with certain images per letter, when you input text (your name for example) and when you press the submit button you would get a series of images in a row that represent each character that you typed.
here is the example that i did...
<html> <?php Hello. After much searching I dont seem to be able to find anyone who has had this issue. I am writing a bounce handler. To get the bounced email of the original recipient I need to download the TEXT part of the bounced message. The original message contained INLINE Images. Many of the bounced messages are returned what appears to be the INLINE image embedded as text in the TEXT part of the email. This means I am having to download TEXT parts which are many MB in size when all i need is about the first 1Kb to get the email address and status code. Does anyone know if there is an IMAP parameter/command that I can tell it to only download the first NNN BYTES of the TEXT Part. I have seen this done using FOPEN to read messages. I have this script from http://lampload.com/...,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens
http://www.jayg.co.u...oad_gallery.php
<form>
<?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form>
any ideas please?
thanks
Hello.
The first page works, but when form actioning to the next i just get a white screen.
This is the white screen page:
<?php session_start(); include 'details.php'; $username = $_POST['username']; $password = $_POST['password']; $pwswdrd = md5($password); if(!empty($_POST['username'])) { $query = mysqli_query($con, "SELECT * FROM users where name = '$username' AND pass = '$pwswdrd'") or die(mysqli_connect_error()); $row = mysqli_fetch_array($query); if(!empty($row['name']) AND !empty($row['pass'])) { $_SESSION['username'] = $row['username']; $_SESSION['id'] = $row['id']; header('Location: index.php'); } } else { echo "You failed to log in."; } ?> - details.php <?php $one=mysqli_connect('.......webhost.com','aee','aaa') or die("Failed to connect to MySQL: " . mysqli_error() ); $db=mysqli_select_db($one,'aee') or die("Failed to connect to MySQL: " . mysqli_error() ); ?> -- What can possibly be wrong?! Hi, I want this output for an XML doc I create via DOM functions. <?xml version="1.0" ?> <letter> <to> <toFirstContact>Bob</toFirstContact> </to> </letter> BUT it outputs nothing to browser screen! Please see code below: Code: [Select] <?php //TEST for REPEAT APPENDAGE $aDoc=new DOMDocument(); $root=$aDoc->createElement("letter"); //create child elem to append to root elem node $newChild1=$aDoc->createElement("to"); //append new child elem <to> to root <letter> $root->appendChild($newChild1); //make elem<toFirstContact> and also create a text, then append to <to> $toFirstContactTag=$aDoc->createElement("toFirstContact"); $textNode1=$aDoc->createTextNode("Bob"); $toFirstContactTag->appendChild($textNode1); //now append new child <toFirstContact> to <to> $newChild1->appendChild($toFirstContactTag); print $aDoc->saveXML(); ?> Any help much appreciated! Hi, Im trying to work out a way to get the New York Lottery's Take 5 results. Theres a few sites that list the winning numbers, i assume automatically as there is alot of lottery games on these sites. what would be the best way to get this? http://www.myfreepost.com/lottery/index.php/us/newyorklottery/takefive/result/ http://www.elite-lottery-results.com/?action=view_game&gid=NY2 Ok, I know how to screen scrape, but I don't know how to screen scrape when there is a login. I've looked this up for awhile, but no luck. I'd like to also make it so I can execute a url when I am logged in on the script for the script, for an example execute this url: http://site.com/data.php?id=9912&submit=1 Thanks in advanced. |