PHP - Ucwords To Format Text Going Into Mysql Table
Hi
I have the following for an input form, I was under the impression that ucwords would format the text into Initial Characters, but this does not do that? What have I done wrong? $ven_name = trim(ucwords(mysql_prep($_POST['ven_name']))); Similar TutorialsHi all - I am parsing info from mysql into a php table but the date being returned is in YYYY-MM-DD format and I want it DD-MM-YYYY. How would I do this? Code at the moment is: Code: [Select] $link = connect(); function get_user_posts(){ $getPosts = mysql_query('SELECT a.id as id,a.post as question, a.answer as answer, a.created as created, a.updated as updated, b.vclogin as admin FROM user_posts as a, admin as b WHERE a.admin_id=b.adminid',connect()); return $getPosts; } Code: [Select] <table class="list"> <tr> <th><?php echo getlocal("upost.post") ?></th> <th><?php echo getlocal("upost.answer") ?></th> <th><?php echo getlocal("upost.admin") ?></th> <th><?php echo getlocal("upost.created") ?></th> <th><?php echo getlocal("upost.updated") ?></th> <th></th> <th></th> </tr> <?php $all_questions = get_user_posts(); while ($question = mysql_fetch_assoc($all_posts)): ?> <tr> <td><?php echo $post['post']?></td> <td><?php echo $post['answer']?></td> <td><?php echo $post['admin']?></td> <td><?php echo $post['created']?></td> <td><?php echo $post['updated']?></td> <td><a href="javascript:user_post('<?php echo $post['id']?>')">edit</a></td> <td><a href="javascript:delete_post('<?php echo $post['id']?>')">delete</a></td> </tr> THANKS! I'm not sure if my problem is with the PHP, MySQL, HTML, or all of the above, but I've used a tutorial from ScriptPlayground (http://scriptplayground.com/tutorials/php/Printing-a-MySQL-table-to-a-dynamic-HTML-table-with-PHP/) to print a table to HTML. My problem isn't that I couldn't get it to work, as you can see from my site, http://dollapal.com/offerlist.php I've used the code on my site, trying to display a list of offers, with links to each, but I actually have two questions: Is there a way to EXCLUDE columns of the table? I would rather not show the 'id' or 'points' columns, since they don't offer any worth to the user. I would also need to hopefully add a dollar sign before the 'pay' quantities if possible. I would also like use the 'title' field as a hyperlink to the URL listed in the 'URL' field, instead of simply printing the URL. Are there any simple ways to do this and not have it look terrible? I have included a copy of the script that I'm working with so far. Thank you in advance! create table mimi (mimiId int(11) not null, mimiBody varchar(255) ); <?php //connecting to database include_once ('conn.php'); $sql ="SELECT mimiId, mimiBody FROM mimi"; $result = mysqli_query($conn, $sql ); $mimi = mysqli_fetch_assoc($result); $mimiId ='<span>No: '.$mimi['mimiId'].'</span>'; $mimiBody ='<p class="leading text-justify">'.$mimi['mimiBody'].'</p>'; ?> //what is next? i want to download pdf or text document after clicking button or link how to do that Hi all, hope some can help because this is giving me more grey hairs than I allready have.
I am trying to solve the following: I'm pulling in JSON data, decoding it to a array which I write to a database. However in the array are social security numbers that I don't want to store (privacyregulations). So I need to check if a row has a social security number and if it has one I want to replace it with 'anonymized'. I have got it to work successfully on a local Xampp test environment using the following script (extract off course): //first anonymize the social security number (ssn) if exists $data = json_decode($jsondata, true);
// then fill the tables foreach($data as $row) {
$insertstatement = mysqli_query($link,"INSERT INTO $tablename (personid, type, ssn) VALUES ('".$row["personid"]."', '".$row["type"]."', '".$row["ssn"]."') ON DUPLICATE KEY UPDATE type = VALUES(type), bsn = VALUES(ssn)");
This leads to a filled table where the ssn's are filled with 'anonymized' if they exist in the array and empty if it does not exist for that row. This is exactly what I want ;-).
Personid type ssn
However, when I run the same script on a Lamp production environment (lamp stack on an Azure server) it does not work. Then the scripts results in totally ignoring the whole row that contains a ssn??
Personid type ssn Hope someone can help to get this working on my production environment as well.
Richard
i want to be able to use ucwords in my whole return results. i know this works. $choice1 = ucwords($rows['auth']); BUT. my query returns 14 $rows of data so i thought of doing this instead of doing a new chunk of code for each row. $sql = "SELECT * from dsgi_serval $column "; $result1=mysql_query($sql); $result = ucwords($'result1'); while($rows=mysql_fetch_array($result)){ echo "$rows"; } needless to say that does not work. i have tried to google this but i only get matches for manual arrays and not an sql query. is there a way of doing this? Thanks I have a registration page I am creating which passes Ajax data from a form to the function ProcessSignUpData. I am trying to use ucwords on this function for the name, address and city form fields and it isn't working. Any Suggestions what be greatly appreciated! If I am not providing enough information, please let me know! Here is what the code looks like: if ($_POST['ProcessSignUpData']) { usleep(3500000); unset($Data); $Data['OldCardNbr'] = substr(preg_replace("/[^0-9]*/", "", $_POST['SavingsClub']), -8); $Data['FName'] = ucwords($_POST['FirstName']); $Data['LName'] = ucwords($_POST['LastName']); $Data['Address1'] = ucwords($_POST['Address1']); $Data['Address2'] = ucwords($_POST['Address2']); $Data['City'] = ucwords($_POST['City']); $Data['State'] = $_POST['State']; $Data['Zip'] = preg_replace("/[^0-9]*/", "", $_POST['ZipCode']); if (ValidateEMail($_POST['EMail'])) $Data['EmailAddr'] = $_POST['EMail']; $Data['HPhone'] = phone_format($_POST['HomePhone']); $Data['WPhone'] = phone_format($_POST['MobilePhone']); $Data['BirthYear'] = preg_replace("/[^0-9]*/", "", $_POST['BirthYear']); $Data['BirthMo'] = preg_replace("/[^0-9]*/", "", $_POST['BirthMonth']); $Data['Sex'] = preg_replace("/[^MF]*/", "", $_POST['Gender']); $NumberOfCards = preg_replace("/[^0-9]*/", "", $_POST['NumberOfCards']); if ($Data['FName'] && $Data['LName'] && $Data['Address1'] && $Data['City'] && $Data['Zip']) { // Check to see if the person is already signed up with a new card number (dupliate signup check) $IsDup = FALSE; // First check database SCVL1 $My->query("select `MembNbr`, `HPhone`, `EmailAddr`, `OldCardNbr` from `member` where `FName` = '" . $My->escape($Data['FName']) . "' and `LName` = '" . $My->escape($Data['LName']) . "' and `State` = '" . $My->escape($Data['State']) . "' and substr(`Zip`, 1, 5) = '" . $My->escape(substr($Data['Zip'], 0, 5)) . "'"); if ($DupCheck = $My->fetchArray()) { do { if (substr($DupCheck['MembNbr'], 0, 1) == "6") { $IsDup = TRUE; if ($Data['EmailAddr'] && $DupCheck['EmailAddr']) { if ($Data['EmailAddr'] != $DupCheck['EmailAddr']) { $IsDup = FALSE; } } if ($Data['HPhone'] && $DupCheck['HPhone']) { if ($Data['HPhone'] != $DupCheck['HPhone']) { $IsDup = FALSE; } } } if ($IsDup === TRUE) break; } while ($DupCheck = $My->fetchArray()); } // Then check database SCVL3 if no dup found in SCVL1 if ($IsDup === FALSE) { $My3->query("select `MembNbr`, `HPhone`, `EmailAddr`, `OldCardNbr` from `tblmember` where `FName` = '" . $My->escape($Data['FName']) . "' and `LName` = '" . $My->escape($Data['LName']) . "' and `State` = '" . $My->escape($Data['State']) . "' and substr(`Zip`, 1, 5) = '" . $My->escape(substr($Data['Zip'], 0, 5)) . "'"); if ($DupCheck = $My3->fetchArray()) { do { if (substr($DupCheck['MembNbr'], 0, 1) == "6") { $IsDup = TRUE; if ($Data['EmailAddr'] && $DupCheck['EmailAddr']) { if ($Data['EmailAddr'] != $DupCheck['EmailAddr']) { $IsDup = FALSE; } } if ($Data['HPhone'] && $DupCheck['HPhone']) { if ($Data['HPhone'] != $DupCheck['HPhone']) { $IsDup = FALSE; } } } if ($IsDup === TRUE) break; } while ($DupCheck = $My3->fetchArray()); } } // Show an error if a dup was found if ($IsDup === TRUE) { new account form has the usual; firstname, last name company, street address etc.
Talents write in ALL uppercase, lowercase everything but proper case.
Don't know where to apply ucwords and strtolower to convert values into proper case.
Code as is:
<form action="https://www.website.com/?page=step3" method="POST" name=myForm id="commentForm" class="cmxform"> I need to add ucwords so that the first letter is caps in POST data. Not sure where to put in within this. echo $_POST['name']; i need a javascript date picker that will put a date in a text flied in the format of Y-m-d so that it can be posted to mysql also i need some kind of php to validite this Hi, I have got a working HTMLarea input form. And using a form, it will input the data from the HTMLarea into a mysql database table. But, the formatting breaks the MySQL query. How can I parse the information so this wouldnt happen? The exact error is: Code: [Select] 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' content in: [INSERT into zen_blog (id, content, active) VALUES ('', content , )!] If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields. Hi, I'm trying to insert this $inceptiondate = date("Y-m-d 12:00:00"); to the database, the Y-m-d does make it to database, but the 12:00pm doesn't. Whenever it reaches the database, it becomes 00:00:00 Where did I got wrong? Thanks hello, lets say i want 3 of the following columns to only display on 1 line always, is there a way to do that? Code: [Select] <th align='center'>Date</th> <th align='center'>Supplier</th> <th align='center'>Requested By</th> <th align='center'>Address of Job</th> <th align='center'>Job Number</th> <th align='center'>P.O. Number</th> <th align='center'>Description</th> <th align='center'>Amount</th> <th align='center'>Notes</th> <th align='center'></th> Hey, I am grabbing a date from a row in my table which is currently formatted as: date("Y-m-d") 2010-09-29 So in my code I have something like this: $row['date']; How do I use this to rearrange the date to look like: 09-29-2010 I looked at the formatting tutorials, but they explain how to format it for the date you are currently setting into a variable. Hello! I have a problem on formatting text witch is being sent by mail. I use this code: Code: [Select] $from = '<someone@example.com>'; $to = 'myemail@mydomain.com'; $message = 'a b c'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: $from" . "\r\n"; mail($to, $subject, $message, $headers); and I'm getting this mail: "a b c" I 've also tried this: Code: [Select] $message = 'a'."\n".' b'."\n".' c'; but i got the same result. As you can see the problem is that i receive amessage that does not contains line brakes. I would be grateful for any kind of help! Hello everyone, What is the best way to take HTML formatted text and overlay it on a image (presumably using php's GD functions)? Unfortunately, HTML tags are ignored and any kind of code is treated as plaintext by imagefttext(). However, I need this HTML DIV box pasted onto an image and I intend to get it done. To make things slightly worst, this is a dynamic, PHP generated DIV box. I had an idea of utilizing some kind of buffering to generate my DIV box, convert that DIV box to an image and finally paste it onto my image using the GD library. If that sounds like a reasonable idea, can someone please help me get started? Thanks in advance, guys! Hi, I am importing data from a csv file into mysql. Everything works fine except that the 'order_date' column in CSV is in the following format mm/dd/yy. Upon import I would like for that format to be changed to yyyy-mm-dd I am not sure how to modify the following code to be able to do so. Any help would be appreciated. <? include "connect.php"; if(isset($_POST['submit'])) { $filename=$_POST['filename']; $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $date = date("Y-m-d"); $import="INSERT into table (order_id, order_status, order_date, todays_date) values ('$data[0]', '$data[1]', '$data[2]', '$date')"; mysql_query($import) or die(mysql_error()); } fclose($handle); print "Import done"; } else { print "<form action='importnew.php' method='post'>"; print "Type file name to import:<br>"; print "<input type='text' name='filename' size='20'><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } ?> Hi people. I have a form which inputs into a database. Here is the code that inserts a yes no option... Code: [Select] <select name = "consent"> <option value = "Yes" <?php if ($_POST['consent'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value = "No" <?php if ($_POST['consent'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> However, I have been asked if I can make it a yes or no checkbox instead. Please can you tell me how I need to code it so that the "yes" or "no" is recorded in the DB. At the moment I just have this Code: [Select] <input name="consent" type="checkbox" value="Yes" />Yes<br /> <input name="consent" type="checkbox" value="No" />No<br /> Thanks in advance VinceG Coming from the world of Excel, I can easily format numbers as $1,500.00, or 27%. When I uploaded a large chunk of data into SQL to be read back through a table, the values all come out as exactly what they were uploaded as. For example, I have an SQL column set as Decimal(19,4) that I want formatted like currency, but which shows up as 1500.0000 in my table, or another column with type decimal(5,2) which shows up as 5500.0000, but which I want to show up as 55%. How do I do this?
Sorry for the beginner question, here I'm trying to retrieve data from the database and display it in the table format. But only table headers are printed, and not the actual values. The count variable is echoing 2 saying that data is present and correctly retrieved. Can anyone help?
<?php include 'connect.php'; error_reporting(E_ALL ^ E_DEPRECATED); error_reporting(E_ERROR | E_PARSE); $sql="SELECT * FROM `resources` as r INNER JOIN `project_resources` as pr ON r.res_id =pr.res_id WHERE project_id='$_POST[project_id]'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($result === FALSE) { die(mysql_error()); } echo "$count"; echo '<table> <tr> <th>Resource ID</th> <th>Resource Name</th> <th>Email</th> <th>Phone Number</th> <th>Reporting Manager</th> <th>Role</th> <th>Designation</th> </tr>'; while ($row = mysql_fetch_array($result)) { echo ' <tr> <td>'.$row['res_id'].'</td> <td>'.$row['res_name'].'</td> <td>'.$row['email'].'</td> <td>'.$row['phone_number'].'</td> <td>'.$row['reporting_manager'].'</td> <td>'.$row['role'].'</td> <td>'.$row['designation'].'</td> </tr>'; } echo ' </table>'; ?> Edited by mac_gyver, 22 September 2014 - 07:25 AM. code tags please I notice that my text gets saved correctly formated in mysql but when I go to display it its not formated anymore. Anyone know what can I do to get it to display correctly? |