Data Format In Application Or Database?
I have found that by far the easiest way to store dates in my LAMP
application is in a text string in the database in Unixtime format.
First of all, what would be the most efficient data type to store this as?
Secondly, in terms of translating into a human readable format, is it
quicker to format the date in the application using date() or in the
database in the select query?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Data Format
I'm building a site for a client, and the access database they've given me wasn't formatted in any specific way. I've converted the database to MySql, but I'm running into a problem with one of the fields. The field contains a list of items that I'll need to output to a list when processed by the script I'm writing. The problem I'm having is the list of items wasn't formatted in any special way. Other then entering all the data by hand, does anyone have any ideas on transforming the data in the field to an array? There are 700+ records and I really don't want to have to edit each one by hand unless it's a last resort. Format Example: Item1 Item 2, continued Item 3 has 6 - parts Item 4 has 7, parts
Format Dates In A Database...
what is the best or easiest format for storing dates in a mysql database? I'm wanting to store a lot of things with a date value and want it to be as easy as possible to read the date from it... I've had problems with getting dates in the past because of how I stupidly stored them. I was thinking of simply having day/month/year e.g: 22/05/1988or should I use a unix timestamp?
Format Data Into A Table
Managed to get this script to out put data and put it into table format. But the idea is to be able to limit the number of data into 3 columns. I put a border = 1 into the table to see whats happening. It seems that the first entry gets into the table and the rest gets listed one after the other with no table around it. Check out the code ! PHP Code:
Using Split To Format Data?
I've read all the forums and can find anything like what i'm trying to do when formatting a date. So tell me if this is possible and if so maybe how I could go about it. I have a csv file to upload to my db. The date is in the format of 8/20/2001. Is there any way that I could split the date with the (/), assign is section a variable name and then format it properly in the db via the variable names?
Export SQL Data Into CSV Format
can any one help me make a function that take in a query then output the results in CSV format ?? i have found here a sample but its not working for me: <? $db = new MyDb; $db->db_connect($host, $dbuser, $password); # connect to database $db->db_select($database); $csv_output = '"column 1","column2"'; $csv_output .= "
What Is The Proper Date Format For A Txt Database?
I would like to know what format should be used when writing to a txt file. I am trying to search between a start date and a ending date and list any variables For example. if (($sDate <= $jdate && $eDate >= $jdate)) then I have it list the variables it will work if searching between months and days but it does not work if I have different years. I will get all years printed out. my date format is m/d/Y 6/13/2001 If I search for example start date = 6/01/2001 and the ending date = 6/09/2001 I will get the correct month and day dates but I also get anything from the year before and including year in the future.
Date & Time Format In Database.
I'm using MySQL database, the problem is I've setup that user input the Date format in dd/mm/yyyy (example: 14may2007) and Time (example: 12:00pm). How do I convert it to Date & Time format in database format before insert into database? Sorry, noob here.
Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format. For example the following text in this format including the lines in stored in the database: Quote“Hello, Welcome to the news for 11/06/07. Thanks” When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this. Quote“Hello, Welcome to the news for 11/06/07. Thanks” How do I get it to display in the format it in displayed in the database?
Change Data Time Format
when I retrieve my date and time from database and display as follow: 2003-03-14 14:42:18 How can I easily change the format into : Mar 14th, 2003, 2:42pm
Forms Data Format (FDF Functions)
Anyone used FDF functions in PHP like to share ideas how to populate, say a HCFA1500.PDF file from a MySQL database? Where do I start :-O ? Do I need to install the PDFlib at all? Or is it included in the PHP libraries already?
How To Send Data In Xml Format To PHP Script
Say I have a web page that uses XForms, which puts the result of the form in XML format. How do I send the result that is in XML format to a PHP script for processing? Do I still use GET or POST? What does the result look like when it gets to the PHP script?
PHP Array Email Data In CSV Format
I have a web form which collects data and then does a POST action to call a PHP file which takes the data and sends it to an email address. This all works fine, but right now when I get the data in my email I get it back as follows: Date Submitted: 7/28/07 Name: Mark Jones I do not want the Labels with the : (I just want the data emailed) Basically what I need to be able to do is easily copy this data into an Excel file when I get it. With the labels include with the :, the data all gets put into the same column in Excel, so I need to remove the labels. I'm pretty sure I have to modify something in my code listed in Red below, but not sure what or if thats the only thing. Code:
Date Format When Inserting Data
I am getting a date entry through POST by a form byt the format enetered by the user is 'dd/mm/yy' .... how could i use MYSQL PHP syntax to insert the proper format as it is default in the table in my database. which function is it?
Format SQL To Display Data In A Group?
Can any one tell me if there is a way to display data from a MySQL DB in groups? For example: May: Item 1 1/05/2007 Item 2 2/05/2007 Item 3 3/05/2007 June: Item 4 1/06/2007 Item 5 2/06/2007 Item 6 3/06/2007 And so on... Obviously i would be after having a title of that current month etc. But would need the data to go and update on its own, so once may has gone, June would be he first month, if you see what i mean?
How To Format Data In A File Which Will Be Open In Excel?
I am trying to generate a file with php from a database extract that i would like to be open in excel. What i need is to format the content of the file in CSV i guess. The 'fgetcsv()' can do the job by formating the content of an existing file. Is there an other option than to create a file with my database content, save it on the server and open/format it with 'fgetcsv()'?
Change Format Style For Datetime Data Type
I don't know how to change the default format style for datetime data type. When I retrieve data from a table the datetime fields are displayed as "day_number month_name Year" but I need it to be displayed as normal form: "month/day/year". I have been trying to do it using setlocal, but I don't know how to use it.
Processing Form Data And Emailing It In Html Format
I have a form that when submitted it just sends a regular email in plain text with all the information. However I would like to be able to format the email so it is more organized with a table that contains the submitted information. However all the tutorials I have gone over does not show how to pull information from the form fields and put them in the html message itself. They just show how to send an email in html format without any form data. My current code below is what I have been experimenting with and just sends plain text. Can anyone give me some assistance as to how to have the form data submit in html? Code:
Suggestion Needed On Data Storage Format In Text File
The project I am developing doesn't involves database. I want to parse the mailbox file (.mbx) and store the summary in the text file for fast retrieval and display of information in the Inbox page. The sugegsted format are as: #1 ID [4 bytes]: Subject [100 bytes]: To Address[100 bytes]: From Address[100 bytes]...etc... #2 Instead of preassining fixed size to variable (as actual data may be much less or can grew to more), we can store the values continuously, seperated by some unique seperator (#|#, *#*, ...) 1324#|#Hi, How are you#|#me@google.com#|#you@google.com#|# ... and so on Which of these will be the efficeint one (as there will be frequent insert/delete/update of the individual information, eg. set message as read ..., delete message ..., new message ...) Also please suggest on how to determine the variable size (100 bytes as in #1), and assign the size to the variable accordingly and read it (differentiate multiple variables) when required.
Looking For A Database-driven Email "contact Manager" Application
I'm going to be collecting lots (a few thousand) email addys. Each of these people will be interested in recieving mail on one or more topics, with an open ended and growing number of topics. Mailman with a BD application behing it might be ideal as it would let users add and delete themselves and each topic would have it's own email list name identity.
Comparing Database Data And New Data
I am trying to create a PHP script that reads in a file, parses it for the data I want and compares it to the data I have in a database. The data is points and ranking information for a Folding@Home Team. Every week someone creates a news item with points gained by each team member for that week and other info. This is done manually and takes a lot of time. I hope for my script to automate as much of it as possible. The script was to run as follows: Download and parse latest statistics into 2D array Compare usernames in array to usernames held in Database Any new usernames and their respective points/rank to be added to database Compare points in 2D array of each user to those held in database. Output username and points gained I thought I had a working script until I actually tested it on real data, and realised I missed something rather obvious - the order of usernames from the parsed file is not going to be the same order as in my database - due to people moving up and down the ranks. So i can't just get a recordset from the db and run a simple loop to compare it to the parsed data. I am not sure how to go about comparing the database information with the parsed data that works around the fact the data could be in any order. The only thing i can think of is: foreach item in $parsed_data_array query database for $parsed_data_array=>username if(number of results == 0) build new insert query for current username else continue I don't know if this works [haven't tested yet] but I can't help feel it is a little DB intensive. There could be up to 200 queries being sent to the database. This can be minimized by adding extra criteria, like ignoring inactive users of course. Is this a viable solution or is there a much better way of doing this?
Getting Data From Database
I created a databae that i added greek text in it and when i try to get the data to echo in a table i get ?.Any help? I also set the collation of the table and the field to greek_general
Getting Data From Database
I have a database with a table named members with columns - id, member name, age etc.. Is there a way I can get the member name from the table members and store it in a variable $name without looping?
Getting Data From Database
I have a script to select data from a database and put it into a new url which the user gets automaticaly directed to that specific page. The problem is that its not getting the data to put into the new url. Code:
Checkbox Data In The Database
I want to display the checkboxes taken from the database from table “const_skills”, but the checkboxes and its values do not appear ($html_skills). Can anyone figure this out. Below is the codes that I’ve been using. Thanks in advance. <?php include "dbinfo.php3"; function get_checkbox_labels($table_name) { /* make an array */ $arr = array(); /* construct the query */ $query = "SELECT * FROM $table_name"; /* execute the query */ $qid = mysql_query($query); /* each row in the result set will be packaged as an object and put in an array */ while($row= mysql_fetch_object($qid)) { $array[count($arr)] = $row; } return $arr; } /* Prints a nicely formatted table of checkbox choices. $arr is an array of objects that contain the choices $num is the number of elements wide we display in the table $width is the value of the width parameter to the table tag $name is the name of the checkbox array $checked is an array of element names that should be checked */ function make_checkbox_html($arr, $num, $width, $name, $checked) { /* create string to hold out html */ $str = ""; /* make it */ $str .= "<table width="$width" border="0">n"; $str .= "<tr>n"; /* determine if we will have to close add a closing tr tag at the end of our table */ if (count($arr) % $num != 0) { $closingTR = true; } $i = 1; if (isset($checked)) { /* if we passed in an array of the checkboxes we want to be displayed as checked */ reset($arr); while (list(, $ele)=each($arr)) { $str .= "<td><input type="checkbox" name="$name" value="$ele->id""; reset($checked); while (list(, $entry)=each($checked)) { if ($entry == $ele->id) { $str .= "checked"; continue; } } $str .= ">"; $str .= "$ele->value"; if ($i % $num == 0) { $str .= "</tr>n<tr>"; } else { $str .= "</td>n"; } $i++; } } else { /* we just want to print the checkboxes. none will have checks */ reset($arr); while (list(, $ele)=each($arr)) { $str .= "<td><input type="checkbox" name="$name" value="$ele->id">"; $str .= "$ele->value"; if ($i % $num == 0) { $str .= "</tr>n<tr>"; } else { $str .= "</td>n"; } $i++; } } /* tack on a closing tr tag if necessary */ if ($closingTR == true) { $str .= "</tr></table>n"; } else { $str .= "</table>n"; } return $str; } /* get the checkbox labels */ $skills = get_checkbox_labels("const_skills"); /* create the html code for a formatted set of checkboxes */ $html_skills = make_checkbox_html($skills, 3, 400, "skills[]",$checked); ?> <html> <body bgcolor="#ffffff" text="#000000" id=all> <br> <form name="skills" method="POST" action="insertskills.php3"> Check off your web development skills: <? echo "$html_skills"; ?> <br> <br> <input type="submit" value="Submit"> </form> </body> </html>
Modify Data In A Database?
I am using PHP to add data to a MySQL database in an HTML form. Does anyone have any code to display all the records and click on one to modify it and update the data?
Inserting Some Data Into Database..
The code I have at the moment creates directories (mkdir) and copys files into them. This seems to work, but I need the variables "$mypath" and "$newfile5" to be inserted into my database. But it won't. It enters the other data such as name and description and creates the folder. Code:
Sending Data To My Database
I have ms access database (im know mysql is better but please bare with me) and within it is a product list. That product list is called and displayed on my product page. After the price of an item has been echo'ed out i have a small text field where the user of the system is required to type the product id ($ProductId) on all the items they wish to select and then proceed to click submit. Once the submit button has been pressed i want to send all of the data typed into the little text fields into a single cell separated by commas in the database. I have some basic code that doesn't correctly do what i want it to. If more than 3 products are listed on a page and i type the product id for any items not in an order E.g. Product 1 <----i want this one Product 2 Product 3 Product 4 Product 5 <-----I wantthis one I just get ',,,' sent tothe database however if i type product id like this: Product 1 <----i want this one Product 2 <----I want this one as well Product 3 <----i want this one too Product 4 Product 5 I get 1,2,3 sent into the database. Code:
Retriving Data From A Database
I have code that lists a number of people from a data and stores it array // select people from first table who are part of group 1 $query= "SELECT personID FROM people WHERE groupID = 1"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while ($row = mysql_fetch_array($result) { $personid = $row["personID"];} The problem is I do not know how many records it will return. I then need to enter all these people into another table. // add people to second table who are part of group 1 $people = 0; while ($people != $numrows) { $query2 = "INSERT INTO people2 (peopleID, groupID) VALUES ('$personid', '1')"; $queryaddperson = mysql_query($query2) or die(mysql_error()); $people++;} Rather than add every single person who is part of group 1 it just keeps adding the first person over and over again to the people2 table.
Got Data From Database But Doesn't Show
I get data from a database and I need to put in a table. the table dynamically adds rows depending on the results from the database. So my rows are getting created but their's nothing in their. What can be the problem here? Code:
Truncated Data From Textarea Box To Database
I have a simple form with a textarea box. The user is supposed to cut/paste text from documents into the textarea box, which is then added using php as a record to a MySQL column of data type mediumtext. The problem - the text keeps getting truncated at about 1800 characters (sometimes more, sometimes less).
Extracting Data From Database Using Three Strings
I am a complete newbie. I have been working on a self-learning project that will ask users for three strings (i.e. name,dob and number. If details are correct, will vector to a new page and display all their other information unique to their name,dob and number. The second page will then display their school,work,address, etc. which is editable. They will then click the submit button at the bottom to save the displayed data (or any changes they made to it) in the database from where it was initially extracted from. Here is the php for the first page which asks the name,dob and number:
Data Not Posting To My Database Php/mysql
I am having a problem postion data from my form into my database. My users visit my site and fill out a form which is suppose to go into my mysql. I check phpMyAdmin to see if the data got there but nothing. Below is my Code. could someone help me out. Code:
How Do You Send Data To A Database Via Checkboxes?
I am using PHP to send and retrieve data from a MySQL database via HTML forms. I am using text boxes and everything is fine. If I have a page with checkboxes on, and the users check them and click on the submit button, how does this show up in the database? Nothing seems to show up for me.
How To Display Data From Database In Different Web Pages?
When we get data from database by use mssql_query(),suppose the data is very large ,it has many rows, and we want display the data in different web pages like many search engines do, my question is how to do that using the same result without call mssql_query() again?
Form Data Not Stored In DataBase
I was trying setting up these scripts following instructions in a book from 2003, so I thought maybe some of the code might be outdated. Basically this is what Is supposed to happen: 1.- Display a form, enter details into fields and click submit. 2.- After having clicked on submit you're redirected to another page that will display the entered values and store them in the MySQL DB specified. Now what happens is that no errors are displayed after clicking on the submit button in the form, but neither are the entered values. In PHPMyAdmin I can see that the Db is still empty. I created a total of 3 files that reside in the same folder: The form, that when clicking on submit is redirected to the next file: Code:
Mailing Data From Mysql Database
I have searched, but didnt find what I need. I am trying to mail someone if a user changes data in my MySQL database, which is being written to by a php script. All is set up, just need to be notified of what data got changed.
Ok Problems Entering Data Into Database
i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have made the database and the blog_id is a primary auto interger what ever table bascly look below the the insert code block to find the code block that makes the table in the database, // Define the query. $query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}', NOW())"; // Execute the query. if (@mysql_query ($query)) { print '<p>The blog entry has been added.</p>' } else { print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } --------------------------------------------------------------------------------------------------------------------------------------------------- // Define the query. $query = 'CREATE TABLE blog_entries ( blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(100) NOT NULL, entry TEXT NOT NULL, date_entered DATETIME NOT NULL )' // Run the query. if (@mysql_query ($query)) { print '<p>The table has been created.</p>' } else { die ('<p>Could not create the table because: <b>' . mysql_error() . '</b>.</p><p>The query being run was: ' . $query . '</p>'); } Quote:
Writing Data To MySQL Database Using PHP
Can anyone tell me why the following code isn't working? $dbh = mysql_connect($host,$user,$pass) or die("Couldn't connect..."); $selected = mysql_select_db($db,$dbh); $name = $_GET['name']; $state = $_GET['state']; $desc = $_GET['desc']; $lat = $_GET['lat']; $lng = $_GET['lng']; $result = mysql_query("INSERT INTO re_cities (name, state, description, lat, lng) VALUES ('$name','$state','$desc','$lat','$lng')"); The script doesn't die when I attempt to connect so I'm assuming that isn't the problem. I'm pretty sure I also get a result because the following code echoes "City Add Successful". if ($result) { echo "City Add Successful"; } else { echo "City Add Unsuccessful"; } However, the data doesn't show up in the database.
Calculating Some Formulas From Database Data
I am doing a project on beetle diversity and need to calculate a few diversity indices for a load of data i have collected. I thought that maybe i could make a program in php to do that for, and save a bit of time (as well as prevent calculation errors). I imagine this could be quite a bit of programming but i have dreamweaver to help me. Now what i have is a MySQL database full of data on beetle diversity with the following tables: Date - the date the sample is from Habitat - one of 9 habitats that i am testing between (ie. grass, stones, birch woodland, etc) Replica - ie 'Repeats', there were two replicas for each habitat from each date (A and B) Trap number - from each replica there were 6 traps Species - the species of beetle that was found in the trap (of course there are often more than one per trap) Number of Individuals - the number of individuals of that species found in that trap What i need to do is calculate Shannon-Weiner, Shannon Equitability and Margalefs Diversity indices for each replica from each date for each habitat (the data for the individual traps will be merged together). I have an idea of how to do it but what i am stumbling at is how to create a recordset which will calculate the total number of individuals for that species from that replica, date & habitat (I) and calculate the number of different species for that replica, date & habitat (S). Once i have S and I i should be able to write the formula in php to create the indices. Ideally this could be done in a way to allow for each repeating areas to be assigned so that all of the indices for that habitat (for each date and replica) could be shown on one page (to save a lot of clicking).
Using Session Data To Query A Database
Basically the title is the general idea of what i'm trying to do, a user logs in, great, his login id is stored (it is also his number on a seperate database) in a session variable. Now that session variable needs to be queried to another database (with all of that users information) to get all of the information on that user back to the original server (not the first database, the first database just has user number, id, and a password field). So I have a question, and if you have answers great! or if you know of the thread that they are on that would also help because i've been searching and haven't found anything yet. 1. How can I query a session variable in a sql statement, do I just put select * from users where '.$_SESSION['mysessionname'].' = usernumber ?
Form Data Not Stored In Database ?
This is the code for a Returns form where I am trying to implement these validations: 1. Check if fields aint empty 2. Check if SESSION_username = username from Customer table and get customer ID use that Customer ID to look up Orders table and find if the ORDER NO. that has been entered is = an order no. in the Orders table i.e. see if the oder no. entered was actually an order placed by the user b4 * Customer table has cust id and username. Order table has only cust ID. returns table will store username from Session so that it can display each user's individual returns. Code:
|