PHP - Adding Text Formatting
Hi there,
This doesn't seem to echo as attempted, is their a way of doing this? $body2 = "Hello $name, \n <strong>I want to make this paragraph bold!</strong>\n"; Displays as: Code: [Select] Hello John Smith, <strong>I want to make this paragraph bold!</strong> I want to format the text making it bold, but it displays the <strong> tags. Thanks Similar TutorialsI must admit that dates and timestamps really confuse me! I have a query that gets a field named "date_purchased" and returns it like this "2010-09-05 09:58:12" What I need to do is add one year to the date, and display it like this "September 5, 2011" Basically, it's displaying the end date of a one year subscription. The database captures the purchase date with the order, so I want to grab that, add a year, and display it to the customer. Any help would be most appreciated! I want a little online users list at the bottom of my page and the color of the username is to match the color defined in the database. but how do i get them to align side by side? if i add them to a <p> they will all appear under neath each other. Heres my current code: $sql=mysql_query("SELECT * FROM ".DB_PREFIX."members WHERE online = 1"); while ($row = mysql_fetch_object($sql)) { echo '<p style="color: #'.$row->username_color.';">'.$row->username.'</p>'; } also i want a comma at the end of each but how do i stop it adding a comma to the end of the last one? I have a dynamic menu (jglidemenu) installed on my site. It works fine on my HTML pages but on my PHP pages the font formatting from the menu's style sheet isn't working and I haven't been able to figure out why. Here's a page where the menu is working correctly: http://www.greenbayeasthighschool.com and here's a page where the formatting fails: http://www.greenbayeasthighschool.com/staff_by_lastname.php This is my first attempt at creating a page with PHP. Is it not possible to use CSS formatting on a page that includes PHP content? Thanks in advance for any help. Not sure if that title encapsulates what I am trying to say, but basically I have the script that can work if the page is on the root of the domain with htaccess, but not in a subfolder. I just want an easy way to have it so if I type in a domain name such as: www.mysite.com/subfolder/hi that it will put "hi" in the page where I want. The code I had was something like: $item = $_GET['item']; if (!$item) $item = "test"; $item2 = str_replace("-", " ", $item); then in the page it would have <?=$item2;?> but I cant get it to work. help please! I am building an Event Registration system, and am thinking that it should put the Attendee's name on the Ticket (and in the database) as a backup. Is there a way to easily (and dynamically) display the same number of Text-Boxes as the # of Attendees entered? For example, let's say the Customer (payor) wants to buy Tickets for herself and 5 friends to a Banjo Festival. Right now, I just have a drop-down box to capture the head-count, but it would be nice to have 5 Text-Boxes (or something appear) so that the Customer can easily type in the Names of the 5 Attendees *without* having to suffer numerous other clicks and/or screens. Follow me? Is there a way to do that? Thanks, Debbie So its a virtual pet script I'm making. This script changes the image of the pet with time. It also puts the user's name,in text on the image. For some reason It doesnt turn out too well= http://amiteka.comli.com/viewpet_forum.php?id=1 Can someone tell me what is wrong with the script or how I can make it show something like; Error on line # <?php require_once('./inc/config.php'); function greaterDate($dformat, $beginDate, $endDate) { $subtract = $endDate - $beginDate; if($subtract > 0) { return 1; } else { return 0; } } function check(){ $pid = mysql_real_escape_string($_GET['id']); $result = mysql_query("SELECT * FROM `pets_adopted` WHERE `id` = '{$pid}'"); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $results = mysql_query("SELECT * FROM `pets_list` WHERE `id` = '{$row [petid]}'"); $pet = mysql_fetch_array($results); $results2 = mysql_query("SELECT * FROM `users` WHERE `id` = '{$row [adopter]}'"); $usercc = mysql_fetch_array($results2); if(greaterDate(".", $row[fulldate], date('Ymd')) > 0) { $im = showpet_forum($pet[adulturl]); $image = imagecreatefrompng($im); return imagepng($image); header('Content-type: image/png'); } elseif(greaterDate(".", $row[halfdate], date('Ymd')) > 0 && greaterDate (".", $row[fulldate], date('Ymd')) <= 0){ $im = showpet_forum($pet[teenurl]); $image = imagecreatefrompng($im); return imagepng($image); header('Content-type: image/png'); } elseif(greaterDate(".", $row[halfdate], date('Ymd')) <= 0){ $im = showpet_forum($pet[babyurl]); $image = imagecreatefrompng($im); return imagepng($image); } } } echo check(); ?> Thank you for any help. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=346474.0 Hi, Has anyone come across an issue when saving DOM to a file and Code: [Select] $document->preserveWhiteSpace = false; $document->formatOutout = true; has no effect? Hi Simple question, how do I reFormat a date. $dateCreated (2012-01-14) to become: 14th jan 2012 So far I have this, but it's not working: Code: [Select] $expDate = explode('-',$dateCreated); $date1 = mktime(0, 0, 0, date('m', $expDate[1]), date('d', $expDate[2]), date('Y', $expDate[0])); $date = date('d m Y', $date1); Thanks Hi, When I do this the result is a date of zeros? $DateAndTime = date('d-m-y', strtotime($DateAndTime)); All I want is a date in format of DD0MM-YYY and the Time in HH:MM::SS Any help would be great! I know it is basic, Thanks in advance Having used unix timestamps in the past formatting the date used to be easy. But since converting to mysql DATETIME im struggling to format it properly. I basically pull the date from the database, convert it using strtotime(), then convert it to a date using date(). The problem is that when i use 'a' to display am/pm the time almost always says am. If the time is 11am then it will display 11am. If it's 12pm then it will display 12pm, but if it comes to 1pm and above it will revert back to 1am. This is the date string I use: date('jS M Y g:i a'); is this due to the fact that mysql DATETIME uses 24 hour clock ('H'), if so is there a way around this? I'm presently formatting surnames like this: Code: [Select] $surname = ucfirst(strtolower($surname))) .. so that SMITH, and smith ... both look like: Smith. That's all fine, but how do I ensure that... O'BRIEN o'brien o' brien ... all look like O'Brien ? That is, where no spaces are allowed to appear in the surname and where the first letter, as well as the one following the apostrophe are both capitalised. TIA Hi there, I need a PHP number format to match one and all of these sequence of numbers: 8500.00 9999.99 15.00 0.00 Hi there, So I have data which I am fetching from two tables link in a one-to-many relationship using the following code: sql = "select authcourses.id as id, title, date_format(closingdate, '%d.%m.%y') as date, name from authcourses inner join authorities on authorityid = authorities.id order by authorityid"; $result = mysqli_query($link, $sql); if(!$result) { $error = 'Unable to get list of authorities'; include '../../error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $authcourses[] = array('name' => $row['name'], 'title' => $row ['title'], 'date' => $row['date'], 'id' => $row['id']); } I then output the data in a table like this: Code: [Select] <table> <thead><th>Title</th><th>Closing Date</th><th>Action</th></thead> <tbody> <?php foreach ($authcourses as $authcourse): ?> <tr> <form action="?" method="post"> <tr> <td><?php htmlout($authcourse['name']); ?></td> <!-- custom function htmlout($text) see helpers.inc.php --> <td><?php htmlout($authcourse['title']); ?></td> <td><?php htmlout($authcourse['date']); ?></td> <td> <input type="hidden" name="id" value="<?php echo $authcourse['id']; ?>" /> <input type="submit" name="action" value="Edit" /> <input type="submit" name="action" value="Delete" /> </td> </tr> </form> <?php endforeach; ?> </tbody> </table> The htmlout() is a custom function which is basically "echo htmlspecialchars($str)", and you can ignore the form stuff. I get an out put like this: York, Course 1, 2011-02-15 York, Course 2, 2011-03-01 Manchester, Course 3, 2011-06-17 Manchester, Course 4, 2011-08-12 Derby, Course 5, 2011-01-10 Barnet, Course 6, 2011-08-19 Barnet, Course 7, 2011-06-23 etc etc... What I want is something like this: York: Course 1, date Course 2, date Manchester: Course 3, date Course 4, date Derby: Course 5, date Barnet: Course 6, date Course 7, date etc.. I guess I'd like to load an array for each of the authorities (cities) with the course info, then I can output it in my form like this: Code: [Select] <?php foreach ($authcourses as $authcourse): ?> <h1><?php htmlout($authcourse['name'] ?>: </h1> <?php foreach ($courses as $course): ?> <p><?php htmlout($course['title'];?><p> <p><?php htmlout($course['date'];?></p> <?php endforeach; ?> <?php endforeach; ?> I hope that makes sense... Any help would be great. Cheers, Mike I always struggle with keeping my annotations pretty. Just about ever IDE beautifies PHP, there are many online PHP beautifiers, and notepad++ and other apps are available. None of them seem to work with annotations. Also, would like to validate them at the same time. Anyone know of any plugins or websites which do this? I would be fine with just cutting and pasting just the comment block and it need not format the entire PHP script (I probably wouldn't even use the PHP portions as git would probably see changes). If nothing is available, suppose I could create one myself. Before doing so, however, would like to better understand best practices. For instance, how many spaces for indentations, what is acceptable to put inline (i.e. the @ORM\Table item should definitely not be on a single line), etc. Thank! /** * @ORM\Entity() * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_position_serie", columns={"test_chart_id", "position"}), @ORM\UniqueConstraint(name="unique_name_serie", columns={"test_chart_id", "name"})}) * @ApiResource( * collectionOperations={ * "get" = { * "method"="GET", * }, * "post" = { * } * }, * itemOperations={ * "get" = { * "openapi_context" = { * "parameters" = { * { * "name" = "nameOfQueryParameter", * "in" = "query", * "description" = "Description goes here", * "schema" = { * "type" = "string" * } * } * } * } * }, * "put" = { * }, * "patch" = { * }, * "delete" = { * } * } * ) */
Hi, I want to chenge the following statement so that numbers ending with ".00" are changed to blank. Many opinions but I haven't got any to work. Any help? <td align=right class="currency">$'.number_format($row['value1'],2).'</td> Hi everyone, I am having some odd issues with sending php generated emails. Essentially, what I'd like to know is how can I ensure they go into the inbox, and not get shunted to the junk mail folder. I assume this is s formatting issue, and it only happens sometimes. I am creating html emails. I have included my headers below: $headers = "From: <Real Money Help>\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; Any help would be appreciated. Thanks. I've been wracking my brain trying to figure this simple problem out and I can't for the life of me figure out the best way to do it. I have the following array: $n = array('81.0', '80.5', '70.5', '67.0', '65.5'); I only want to display the numbers to one decimal place if it's not a whole number, like so. 81 80.5 70.5 67 65.5 I've tried looking for a solution with sprintf(), rtrim() and number_format(), but what's the best way to do it? Regards Rich Hi all, I have features on my website which require a time limit untill they can do the thing agian, but at the current mintue ive got the time in seconds. How can I make a function which will give the time in minutes instaid of seconds. Example: If it was a 2 mintue waiting time instaid of being 120 Seconds it will be 2min(s) 0sec(s). Example of my Current Code: $timewaiting = time() + 160; // Waiting time. (2min) if ($user->lasttime > time()){ $howlongleft = $user->lasttime - time(); echo ("You must wait $howlongleft"); Thanks for any help given. |