473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

From MYSQL DB to Textbox Problem

usually, when i have questions regarding my DB systems, i just google, and i always find this forum very helpful, so i decided to join this forum and ask this question i coulndt find on the net, 'coz i think you guys know a lot about this:

I have this Datetime field in my mysql DB, which i queried with the SELECT command. now in my page, i have this input field for datetime. in this input box, i would like to place the value in my MYSQL DB as a default value, but when i tried to do this:

[PHP]
<input type="text" name="date_time" value =<? printf("%s",$date_time); ?> >
[/PHP]

it only outputs the date, and not include the time.
i tried to output what was in the variable before the input box and what i got was this:

2008-04-02 10:30:00

but in the box, it only showed

2008-04-02.

here's the select statement and php code i used at the top of the page.. what am i doing wrong?
Expand|Select|Wrap|Line Numbers
  1. SELECT DATE_FORMAT(date_time,'%Y-%m-%d %H:%i:%s'),
  2. FROM project WHERE project.ctrl_no = '$proj_id'
  3.  
[PHP]$date_time = $row[0];[/PHP]
Apr 3 '08 #1
3 1420
ronverdonk
4,258 Expert 4TB
Since there are 'strange' characters in the value field, like a blank, you have to enclose the value in the input statement within quotes. Like this[php]<input type="text" name="date_time1" value ="<? printf("%s",$date_time); ?>" >

or

<input type="text" name="date_time2" value ="<? echo "$date_time;" ?>" >[/php]Ronald
Apr 3 '08 #2
Since there are 'strange' characters in the value field, like a blank, you have to enclose the value in the input statement within quotes. Like this[php]<input type="text" name="date_time1" value ="<? printf("%s",$date_time); ?>" >

or

<input type="text" name="date_time2" value ="<? echo "$date_time;" ?>" >[/php]Ronald

i see.. il try this one out.. ill come back here if i have some more problems. thanks!:D i really appreciate it.
Apr 3 '08 #3
ronverdonk
4,258 Expert 4TB
Glad I could assist. See you around.

Ronald
Apr 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Piet | last post by:
Hello wxPythoneers. I have a problem with a dialog box derived from wxFrame which has a wxComboBox as main element. Depending on the entry selected from the ComboBox, the dialog box will be...
0
by: Suki | last post by:
Hi, I am trying to write a C# windows application. this application have one textbox (with chinese word by default) and one button. This button will connect to mySQL and retrieve one record (in...
2
by: ME | last post by:
I am getting: "ERROR SQLBindParameter not used for all parameters" when attempting to run the following code: Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As...
1
by: TN Bella | last post by:
Hello, I was looking through the older posts for a solution to this problem, but I am still confused on how to fix my problem. There are two dates on my form, one (txtInvDate) is entered by the...
1
by: pete | last post by:
I seem unable to get the FormView with the SqlDataSource control in ASP.NET 2.0 beta 2 to insert into my MySQL 4.11 database corectly. When I run the page and click on the Insert link a SQL insert...
3
by: Phi | last post by:
Hi, I hope somebody could help me with this problem. I would like to make a form to add and delete records from my ms access database. I've found most of the codes from the internet and...
0
by: Allan Kim Jensen | last post by:
Hello, I am trying to retrieve data from a MySql database using ASP.net, and it works fine when putting the result into a gridview (Code provided in the end of this mail). However, I'd like...
1
by: tomi.trescak | last post by:
Hi I have a problem with storing rich text in MySQL. I store rich text in MySQL (in column with type "text") which i get from Rich Textbox control. When i do reverse processing by trying to...
2
by: blitzztriger | last post by:
Hello!! how do i insert values into mysql , after parsing a submiting textbox?? I made the arrays, so this should be a basic insertion of them in the db, but something is missing, or in the wrong...
1
by: gubbachchi | last post by:
Hi, For my project I have a "add" button, upon clicking it, it will take the user to next page where there will be a text box and list of data displayed below it which is fetched from mysql...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.