PHP - Wordpress- Displaying Date Via. Image
Hi, everyone. I am trying to put together a WordPress for a client and although I hate asking for help - I am at a total standstill! She wants date tabs on the left of each post (on the main homepage and then each post; NOT pages- obviously, since those aren't 'dated', per say...).
Here is the function.php code I am using: Code: [Select] // custom date tab - creates two divs // first div pulls in a background png image named by date // and adds year dynamically. Placed via css to left of post as // a hanging tab. remove_action('genesis_before_post_content', 'genesis_post_info'); add_action('genesis_before_post_content', 'family_tree_post_info'); function family_tree_post_info() { if(is_page()) return; // don't do post-info on pages echo '<div class="post-date-wrap">'; echo '<div class="post-date post-date-background" style="background:url('; echo CHILD_URL;; echo '/images/date'; echo the_time('F'); echo '/'; echo the_time('M'); echo '.png) no-repeat 4px -3px">'; echo the_time('Y'); echo '</div>'; echo '</div>'; echo '<div class="post-info">'; genesis_post_comments_link(__('Leave a Comment', 'child'), __('1 Comment', 'child'), __('% Comments', 'child')); edit_post_link(__('(Edit)', 'child'), '', ''); // if logged in echo '</div>'; } This shouldn't matter [much] - but here is the style.css for the post-dat: Code: [Select] .post-date-wrap { width: 65px; height: 73px; } .content-sidebar .post-date-wrap { float: left; margin-top: -42px; margin-left: -107px; background: url(images/dates/bgd-left.png) no-repeat top left; } .content-sidebar-sidebar .post-date-wrap { float: left; margin-top: -42px; margin-left: -84px; background: url(images/dates/bgd-left.png) no-repeat top left; } .full-width-content .post-date-wrap { float: left; margin-top: -42px; margin-left: -89px; background: url(images/dates/bgd-left.png) no-repeat top left; } .sidebar-content .post-date-wrap { width: 65px; height: 73px; float: right; margin-top: -42px; margin-right: -89px; background: url(images/dates/bgd-right.png) no-repeat top left; } .sidebar-sidebar-content .post-date-wrap { width: 65px; height: 73px; float: right; margin-top: -42px; margin-right: -86px; background: url(images/dates/bgd-right.png) no-repeat top left; } .sidebar-content-sidebar .post-date-wrap, .sidebar-content-sidebar .post-date { visibility: collapse; height: 0; width: 0; } .post-date { width: 62px; height: 17px; display: inline; text-align: center; color: #4e260d; padding: 50px 0 0 5px; font-size: 9px; } .content-sidebar .post-date, .content-sidebar-sidebar .post-date, .full-width-content .post-date { float: left; } .sidebar-content .post-date, .sidebar-sidebar-content .post-date { float: right; } Here are two pictures: * I have one of these for every day; for each month - found in images/dates - thereafter organized by months (in written out for October, November; then 1.png; 2.png, etc. for each DAY of the month) This is how it is coming up right now; only the year (that really small lettering that says 2011): I need the images with the month & date to appear inside of that box/tab. I have been working on this for too long and cannot get it to go. My 'thing' is design, so I really hope you can all help me! I just can't get PHP down.. I am sure it is something so ridiculous that I cannot see. Thanks for your help!! - Nicole Similar TutorialsI was wondering if someone could help me out with calculating and displaing dates. Below i posted html of my page and also php for it. It has a field called "DATE1" thats where visitors input the date, after that it gets posted to db and i pull it and disply it in a grid on my site. I would also like to have a column that shows time elapsed between the "DATE1" and current date. I sorta figured how to calculate the dates using the php, but really stuck on how do i actually display it now. from what i been told so far i shouldn't create a new column for that, instead calculate and display the values on the fly, could some step me through this please, or get me started... thanks so much! my html Code: [Select] <form id="signupForm" method="POST" action="processform.php"> <div> <fieldset> <legend>Signup Form</legend> <label for="Country">*Country:</label> <select name="Country"> <option value="">-----</option> <option value="Canada">Canada</option> <option value="UK">UK</option> <option value="France">France</option></select></div></p> <p><label for="Nationality">*Nationality:</label> <div><select name="Nationality"> <option value="">-----</option> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option></select></div></p> <p><label for="Province">*Province:</label> <div><select name="Province"> <option value="">-----</option> <option value="British Columbia">British Columbia</option> <option value="Alberta">Alberta</option> <option value="Saskatchewan">Saskatchewan</option></select></div></p> <p><label for="DATE1">*Date:</label> <div><select name="day" id="Date1" class="regularfont"><option value="" selected="selected"></option> <option value="1">01</option> <option value="2">02</option> <option value="3">03</option></select> <select name="month" id="Date2" class="regularfont"><option value="" selected="selected"></option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option></select> <select name="year" id="Date3" class="regularfont"><option value="" selected="selected"></option> <option value="2014">2014</option> <option value="2013">2013</option> <option value="2012">2012</option></select> </fieldset> </div> <p> <div align="center"><input type="submit" name="submit" value="Submit your entry"></div> </p> </form> <p> Code: [Select] <?PHP $hostname = "localhost"; $db_user = ""; $db_password = ""; $database = ""; $db_table = ""; $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$db); //here i use this to calculate the date but really unsure how to further display the results Code: [Select] if (isset($_REQUEST['submit'])) { // Get current time, or input time like in $date2 $date1 = time(); // Get the timestamp of DATE1 $date2 = mktime(0,0,0,date($_POST['month']),date($_POST['day']),date($_POST['year'])); $dateDiff = $date1 - $date2; $TotalTime = floor($dateDiff/(60*60*24)); echo "$TotalTime"; } for posting to db Code: [Select] if(isSet($_POST['submit'])) { $country = mysql_real_escape_string($_POST['Country']); $nationality = mysql_real_escape_string($_POST['Nationality']); $province = mysql_real_escape_string($_POST['Province']); $date = $_POST['day'].'-'.$_POST['month'].'-'.$_POST['year']; $myQuery = "INSERT INTO {$db_table} (`Country`,`Nationality`,`Province`,`DATE1`) VALUES ('{$country}','{$nationality}','{$province}','{$date}')"); if(mysql_query($myQuery)) { echo 'Record inserted.'; } else { echo 'An error has occurred: '.mysql_error(); } } ?> Hi, im trying to calculate and display a time elapsed from known date in db. however im having trouble displaying it. other values display no problem, just cant calculate and display date on the fly. does anyone see a problem with my query? thank you. Code: [Select] <?php include('config.php'); $uname=$_SESSION['username']; if($_SESSION['username']){ $sql="SELECT country, nationality, passportDate FROM country WHERE uname='$uname'"; $result = mysql_query($sql) or die(mysql_error()); $passportDate _ts = strtotime($row['passportDate ']); $passportDate _str = date("M-d-Y", $passportDate _ts); $TotalTime = floor((time() - $passportDate _ts)/(60*60*24)) . ' days'; while($row=mysql_fetch_array($result)) { echo "<table border='0'> <tr> <th>Nationality</font></th> <th>Country</font></th> <th>Passport Seent Date</font></th> <th>Time Elapsed</font></th> </tr>"; echo "<tr>"; echo "<td>" . $row['nationality']."</td>"; echo "<td>" . $row['country'] . "</td>"; echo "<td>" . $row['passportDate '] . "</td>"; echo "<td>" . ('$TotalTime') . "</td>"; echo "</tr>"; } echo "</table>"; } ?> Okay, I have a field called "created" in my `users` table, and I'd like to be able to view it in-game on an administrator panel. However, it's being captured in a long number format (i.e. 1335076320) which, I believe, has to deal with seconds and such. How can I take that number and convert it to an actual date/time output? Here's how I currently have it coded in my php form: <tr><td width="20%">Registered On:</td><td>{{created}}</td></tr> So, obviously it's not converting it to any format, rather just pulling that 1335076320 number out. Thanks in advance! I am writing code in the ZEND framework and i need to get the current day in like 2012-02-03: In the controller: Code: [Select] $time=date('YYYY-mm-dd',time()); $this->view->time=$time;In view: Code: [Select] <?php echo $this->time; ?> Output: 2012201220122012-0202-0303 I dont know why it is displaying like that instead of once...there is no loop anywhere. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348171.0 I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. I am using this code Code: [Select] <?php echo IMAGES_HEADER . "header_02.jpg"; ?> Instead of displaying the actual image on my site I am getting the path of the image. It is displaying "images/header/header_02.jpg" instead. Thank You in advance i have a db which store jpg image thru the upload prg code in php.But the image is not displayed properly in the <img> and also when i echo the blob data. how to correct this code.i am pasting the code below $result = mysql_query("select cover from Movies where movie_id=4"); $row = mysql_fetch_row($result); $data = base64_decode($row[0]); $im = imagecreatefromstring($row[0]); imagejpeg($im); header('Content-type: ' . $mime); // 'image/jpeg' for JPEG images echo $data; <img src=<?php echo $data;?>> Hi, I am uploading an image to a folder and I need to display the uploaded image in a new page. This is my code for the upload: Code: [Select] <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","2000000"); //This function reads the extension of the file. It is used to determine if the // file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no // error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['upload'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and // will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Tipo de imagen no permitido.</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>La imagen es demasiado grande.</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images //folder) $newname="banners/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Error al subir la imagen.</h1>'; $errors=1; }}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>La imagen se ha cargado correctamente</h1>"; } $query = "INSERT INTO banner_rotator.t_banners (banner_path) ". "VALUES ('$newname')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); //echo "<br>Files uploaded<br>"; header("Location: PC_cropbanner.php"); }Sowhat I need to do is to display the uploaded image in PC_cropbanner.php. How can I do this? Hi all, I have this script below where I am trying to display a default image if an image can not be found. For some reason though it is not working. <?php foreach (glob('./aircraft/' . $rowX['reg'] . '[0-8].jpg') as $file) { if (file_exists($file)) { echo "<img src=\"" . $file . "\" /><br />"; } else { echo "><img src=\"aircraft/wrightflyer.jpg\" /><br />";} } ?> I just can't get anything right today! Now I am trying to have a list of images, and when the user clicks on the image, the next page will display the image along with other fields for that record. I am sending the id through the hyperlink to the next page, and I have echoed it to ensure it's comign through, but I cannot get anythign to display ont he next page. What am I doin wrong? Here is the link to the page. If you click on one of the images, you 'll see that the next page is empty: http://webdesignsbyliz.com/wdbl_wordpress/test-submit/ Here is my code: Code: [Select] this is the gallery <?php $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); $id = mysql_result($all_records_res, 0, 'id'); while($nt=mysql_fetch_array($all_records_res)){ echo "<a href=http://webdesignsbyliz.com/wdbl_wordpress/test-display/?id=" .$nt['id']." ><img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/".$nt['image']." width=133 height=86></a>"; } ?> display page: Code: [Select] <?php $id = $_GET['id']; $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery WHERE id = $_GET[id]"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); $id = mysql_result($all_records_res, 0, 'id'); while($nt=mysql_fetch_array($all_records_res)){ echo "<img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/".$nt['image']." width=133 height=86></a>"; } ?> What an I doing wrong this time?? :-( Now I am trying to display the images from my table and I have almost got it working, except for one small thing --- it seems to be displaying all the records, but instead of displaying the right image for each record, it's displaying the same image across all the records. Can anyone tell me what I have done wrong? Code: [Select] this is the gallery <?php $dbhost = 'localhost'; $dbuser = 'webdes17_lizkula'; $dbpass = 'minimoon'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'webdes17_jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); while($nt=mysql_fetch_array($all_records_res)){ echo "<img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/$image>"; } ?> I'm guessing I have the $image variable in the wrong place, but when I tried placing it within the while statement, the page never loaded, and instead acted like it was loading forever. What am I doing wrong? Here is the link to the page so you can see what is happening: http://webdesignsbyliz.com/wdbl_wordpress/test-submit/ I must be doing something incredibly daft, because I'm incredibly new at this. I have an image stored in a DB under a table called 'images' and I want to display it on my website but instead of that image I get the error: Warning: Cannot modify header information - headers already sent by (output started at /home/... This is how I'm trying to achieve it. Any ideas where I'm doing wrong? Thanks. Code: [Select] <?php $user="###"; $password="###"; $database="###"; $con = mysql_connect(localhost,$user,$password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>MySite</title> </head> <body> <div id="container"> <?php include("../navbar.php"); ?> <div id="left-content"></div> <div id="right-content"> <?php $item = $_GET['item']; $query = "SELECT * FROM main WHERE Ref='$item'"; $result = mysql_query($query) or die("Oops" .mysql_error()); $row = mysql_fetch_array($result,MYSQL_BOTH) or die("Oops" .mysql_error()); extract($row); $query2 = "SELECT image FROM main WHERE Ref='$item'"; // the result of the query $result2 = mysql_query($query2) or die("Invalid query: " . mysql_error()); header("Content-type: image/jpg"); echo mysql_result($result2, 0,'image'); echo "<p><strong>Name: </strong>".$FirstName." - ".$SecondName."</p>"; mysql_close($con); ?> </div> <br /> <?php include("../footer.php"); ?> </div> </div> </body> </html> MOD EDIT: [code] . . . [/code] BBCode tags added. I've taken this eg from php manual site for displaying txt on image wonder why it is not working Code: [Select] <?php // Create a 300x150 image $im = imagecreatetruecolor(300, 150); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); // Set the background to be white imagefilledrectangle($im, 0, 0, 299, 299, $white); // Path to our font file $font = './arial.ttf'; // First we create our bounding box for the first text $bbox = imagettfbbox(10, 45, $font, 'Powered by PHP ' . phpversion()); // This is our cordinates for X and Y $x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 25; $y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5; // Write it imagettftext($im, 10, 45, $x, $y, $black, $font, 'Powered by PHP ' . phpversion()); // Create the next bounding box for the second text $bbox = imagettfbbox(10, 45, $font, 'and Zend Engine ' . zend_version()); // Set the cordinates so its next to the first text $x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) + 10; $y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5; // Write it imagettftext($im, 10, 45, $x, $y, $black, $font, 'and Zend Engine ' . zend_version()); // Output to browser header('Content-Type: image/png'); imagepng($im); imagedestroy($im); ?> I am having trouble with displaying an image from a url. In the following code if I echo out $test I get the url of the image. However, in the current code I am trying to display the image, but the only thing that gets displayed is a small broken image in the upper left.
$html = file_get_contents($website.$criteria); $dom = new DOMDocument; @$dom->loadHTML($html); $links = $dom->getElementsByTagName('img'); header('Content-Type: image/png'); foreach ($links as $link){ $test = $link->getAttribute('src'); echo file_get_contents($test); }image that gets displayed: http://imgur.com/epfF3wJ Hi everyone, Sorry not sure if this is a php or html problem. Im using php and a html form to upload images to my site, i have made it so that jpg, jpeg, gif and png images can be uploaded. The problem im having is displaying the image. Code: [Select] <img src="images/<?php echo $name ?>.jpg" /> That works fine if a jpg was uploaded, but what if a png or a gif was uploaded? The $name is going to be unique, there will not be more than one image with the same name, so what do i have to do to display the image regardless of what the extension is? Thanks Hi everyone, i am just trying to learn php for a bit of fun really and started making a sort of 'facebook' website. I am having trouble however trying to display different users images, for example when trying to find a correct 'friend' only the image of the last result is being shown for all people with the same name... here is my code below, if anyone can help me out that would be great file 1 $count=1; while ($numids>=$count){ echo "<form method=\"post\" action=\"friendadded.php\">"; $frienduserid=$_SESSION["passedid[$ii]"]; $friendfirstname=$_SESSION["passedfirstname[$ff]"]; $friendlastname=$_SESSION["passedlastname[$ll]"]; $_SESSION['friendsuserpicid'] = $frienduserid; echo "<table width=\"700\" height=\"50\" border=\"1\" align=\"center\">"; echo "<tr>"; echo "<th></th>"; echo "<th>First Name</th>"; echo "<th>Last Name</th>"; echo "</tr>"; echo "<tr>"; echo "<td><center>"; echo "<img border=\'0\' src=\"frienduserpic.php\" width=\"80\" height=\"80\" align=\"middle\"/>"; echo "</center></td>"; echo "<td><center>"; echo $friendfirstname; echo "</center></td>"; echo "<td><center>"; echo $friendlastname; echo "</center></td>"; echo "</tr>"; echo "</table>"; echo "<center><input type=\"submit\" value=\"Add this friend\" name=\"Add Friend\"></center><br/>"; $ii=$ii+1; $ff=$ff+1; $ll=$ll+1; $count=$count+1; echo "</form>"; } file 2 session_start(); $passeduserid=$_SESSION['friendsuserpicid']; $timespost=$_SESSION['postednum']; $host= $username= $password= $db_name= $tbl_name= mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $query = mysql_query("SELECT * FROM $tbl_name WHERE picid='".$passeduserid."'"); $row = mysql_fetch_array($query); $content = $row['image']; header("Content-type: image/jpeg"); echo $content; Thanks in advance Good day: Im trying to display an image from a folder and the image name is retrieved by a query. The query is getting the image name all right but the image is not displaying. This is the code im using for the image display Code: [Select] <?php $aid = 1; $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="SELECT imagename, description FROM articles_description WHERE id='$aid'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table width ="1000" border="1" cellspacing="2" cellpadding="2"> </tr> <?php $j=0; while ($j < $num) { $f8=mysql_result($result,$i,"description"); $f9=mysql_result($result,$i,"imagename") ?> <tr> <td valign="top"> <img src="images/'.$f9.'; ?>" alt="" name="picture" width="100" height="100" border="1" /></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td> </tr> <tr> </tr> <?php $j++; } ?> Any help will be appreciated Hi guys, I have followed a tutorial and made a members only area using sessions. The user can upload an image and which gets renamed as their username. I was hoping to display all the users images that are logged in. I know how to do it with a single image by just setting the img src as the session username but I don't know how I would display multiple images if more than one person were logged in. Is it even possible? Hi guys, I have a page that lets you upload an image to a an ftp server. Now I am trying to create a page that will get those images and display them in a web page. I am trying to do this with php. Does anyone know if it can be done? Thanks guys, |