Photo Resize when loading... PHP photo from server - html

I'm wondering if anyone could provide me with some advice on where I went wrong. I'm trying to get a photo to resize when loaded in a DIV but the photo keeps taking it's own dimensions. Does anyone have any idea why my code isn't working? Thank you in advance!
if($row['coverphoto'] === NULL){
echo"<li>";
echo"<img src='images/slider-4.jpg'>";
echo "<div class='banner'>Customize Your Banner!</div>";
echo "</li>";
}
else{
echo "<li>";
echo "<img style='height:auto; width:auto; max-width:1025px; max-height:503px;' src='/coverphotos/" . $row['coverphoto'] . "'/><br />";
echo "<div class='banner'>Customize Your Banner!</div>";
echo "</li>";
}
?>

Try this,
else{
echo "<li>";
echo "<div style="width:50px;height:50px;"><img style='height:50px; width:50px;' src='/coverphotos/" . $row['coverphoto'] . "'/></div><br />";
echo "<div class='banner'>Customize Your Banner!</div>";
echo "</li>";
}
If it is not worked means, please check your, css file
<li>
styles. May that style makes this mistake.

Related

How to make div color appear in front of another?

I want to know what is the wrong with following code; I want to make the inner div color appear as a part of the outer div color. I am using this for a percentage poll bar:
echo '<div style="width:130px; height:20px; background-color:#ecf2f9; overflow:hidden;">';
echo '<div style="width:<?php print $percent1; ?>%; background-color:#ff33cc; position:relative; z-index:3"></div>';
echo '</div>';
or if there will be another solution to get the result i need.
Thanks in advance for your help
In your case it is relatively simple. Just set the hight for the inner div and you are done ;)
A DIV has no default height. That's the problem.
Example:
echo '<div style="width:130px; background-color:#ecf2f9;">';
echo '<div style="width:<?php print $percent1; ?>%; background-color:#ff33cc; height:20px;"></div>';
echo '</div>';
You can see a plain HTML example of your bar here:
https://jsfiddle.net/eaz1vbex/
Beside that, using <?php print $percent1; ?> that way won't work, because echo outputs the content without further parsing by the PHP interpreter. If you want to keep the above style of code, you should change it to the following before continue reading:
echo '<div style="width:130px; background-color:#ecf2f9;">';
echo '<div style="width:' . $percent1 . '%; background-color:#ff33cc; height:20px;"></div>';
echo '</div>';
Alternatively:
echo "<div style='width:130px; background-color:#ecf2f9;'>";
echo "<div style='width:$percent1%; background-color:#ff33cc; height:20px;'></div>";
echo "</div>";
Please read this for better understanding:
http://php.net/manual/en/function.echo.php
Hints:
You should use CSS for all style attributes (except width, which is dynamic). Using the style tag is not recommended because it makes it hard to maintain and redesign later in the product lifecycle. It also bloats up output.
You maybe want to use some sort of template engine or at least the "here document"-syntax, for better maintainability of markup.
Example:
echo <<<END
<div style="width:130px; background-color:#ecf2f9;">
<div style="width:$percent1%; background-color:#ff33cc; height:20px;"></div>
</div>
END;
Example with seperate CSS:
CSS:
.progressBar { width:130px; background-color: #ecf2f9; }
.progressBar .progress { background-color:#FF33cc; height: 20px; }
PHP:
echo <<<END
<div class="progressBar">
<div style="width:$percent1%;" class="progress"></div>
</div>
END;
See: https://jsfiddle.net/fchp5aqa/
it's work : i have set a height : 20px and your $percent1 did not print !! so i change it and fix it. i think it enough to understand what i done!!
echo '<div style="width:130px; height:20px; background-color:red; overflow:hidden;">';
echo '<div style="width:'.$percent1.'%; background-color:blue; position:relative; z-index:3; height:20px;"></div>';
echo '</div>';

How can I allow user to upload own PDF and have it displayed?

I have a website for school where every teacher is going to have a page. Each teacher's page will have a spot for them to upload a PDF. I want this to then show in a viewer on the page so students see the Viewer when they access it.
How would I code into the website allowing the user to upload a PDF and not have it replaced until somebody else uploads a PDF?
so far I have the code to upload a document.
<form method="POST" enctype="multipart/form-data" action="fup.cgi">
File to upload: <input type="file" name="upfile"><br/>
Notes about the file: <input type="text" name="note"><br/>
<br/>
<input type="submit" value="Press"> to upload the file!
</form>
How can I get it to go into a viewer below? and that it saves until replaced.
1 - First thing you are not able to upload file to server but your form action is claiming to use CGI,
2 - Second i cant really get what you want but the following code can upload files to server its in PHP and otherthing are you using SQL or what Database are you using it seems you also need database
<?php
set_time_limit(0);
if(!is_dir("uploads")){
$uploadDir = mkdir("uploads");
}
$allowedExts = array("pdf", "docx", "doc");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "application/pdf")
|| ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|| ($_FILES["file"]["type"] == "application/msword"))
&& ($_FILES["file"]["size"] < 200000000000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("/uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/uploads/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
Do you want to display pdf thumb, icon, or read the pdf

Table works correctly only in Chrome

Please, can someone explain why my classic PHP table only showing correct in Chrome, but in Firefox or IE content of the table goes outside of the <div>? Everything that is in style.css effect correctly on table while displaying in Chrome, but don't react in Firefox or IE.
My table:
<?php
include('db.php');
$sqlget="SELECT * FROM table ORDER BY timestamp_oglas DESC";
$sqldata= mysql_query($sqlget);
echo"<table>";
while ($row=mysql_fetch_array($sqldata)) {
echo "<tr><td>";
echo"<b><font color='#e73535'>".$row['heading']."</font></b>";
echo "<br/>";
echo $row['text'];
echo "<br/>";
echo "<img src=\"download.php?id=".$row['id']."\"><br />\n";
echo "<div style='text-align:right'><font size='1px'>".$row['timestamp']." </font></div>";
echo '<br />';
echo "</td></tr>";
}
echo"</table>";?>
My .css:
table{width:95%;margin-left:auto; margin-right:auto;margin-top:25px;}
Screenshot (Chrome):
http://img708.imageshack.us/img708/9603/r40m.png
Screenshot (Firefox):
I found the sollution. I added this line table-layout: fixed; in style.css. Now works perfectly all browsers.

Wordpress Logout Link

How could I add a logout link in the else portion of code, after the "echo $upme->display();" ...
<?php
global $upme;
if (!is_user_logged_in()) {
echo $upme->show_registration();
echo $upme->login();
}
else { echo $upme->display();
}
?>
I tried a few things including the below code but I keep getting internal error ...
<?php
global $upme;
$html1 = 'Logout';
if (!is_user_logged_in()) {
echo $upme->show_registration();
echo $upme->login();
}
else { echo $upme->display();
echo $html1;
}
?>
Thank You
There's a small syntax error:
$html1 = 'Logout';
500 is generally an "I can't find that" error. What page is this from? get_permalink may be returning false. Try outputting that function to see what you get back.
<?php echo get_permalink(); ?>

Back button on the image preview

I have a minor problem, i just want a simple image preview with a go back button or something similar, I made
<div id="image1">
<a href="../assets/image_large1.jpg"><img src="../assets/image_1.jpg" width="160" height="107" alt="Example 1" />
</div>
but I don't know how to put a button inside
how could I do it?
In the most simple solution to your problem, I would do special show_image.php page, for example:
<?php
$directory = 'assets/';
$filename = $_GET['image'];
if(empty($filename) || is_file( $directory . $filename ))
{
echo 'No such image!';
}
else
{
echo '<img src="' . $directory . $filename . '" />';
}
echo '<br />';
echo 'Go back';
exit;
And link for the image will be: http://mysite.com/show_image.php?image=image_1.jpg
Of course this code should be made more secure and this thing could be done other ways.