• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

MYSQL TIME STAMP - Only display the date when I create a form

I have a MYSQL database with a date timestamp field, when I run a PHP script to display the date and time field it will only display the Date.
I like to bwe able to see the time stamp as well, and I am hoping once I get this correct i wil be able to update the date time for this interface.

Loooking for advice....

Sample of report output
$con = mysql_connect("domain.com","account","passowrd");
 // Check connection
 if (!$con) {
   die ('Could not Connect to MySQL: ' . mysql_error());


if (isset($_POST['update'])){
$UpdateQuery = "UPDATE ITProductSale SET ItemNumber='$_POST[itemnumber]', StartingDate='$_POST[startingdate]', EndingDate='$_POST[endingdate]', SalePrice='$_POST[saleprice]'";
mysql_query($UpdateQuery, $con);


$Stime = 

$sql = "Select * from ITProductSale order by Itemnumber";
$mydata = mysql_query($sql,$con);
echo "<table border=1>
<th> Item Number </th>
<th> Starting Date / Time </th>
<th> Ending Date / Time </th>
<th> Sale Price </th>
while ($record = mysql_fetch_array($mydata) ){
	echo "<form action = updatedata3.php method=post>";
	echo "<tr>";
	echo "<td>" . "<input type=text name=itemnumber value=" . $record['ItemNumber'] . " </td>";
	echo "<td>" . "<input type=text name=startingdate value=" . $record['StartingDate'] . " </td>";
	echo "<td>" . "<input type=text name=endingdate value=" . $record['EndingDate'] . " </td>";
	echo "<td>" . "<input type=text name=saleprice value=" . $record['SalePrice'] . " </td>";
	echo "<td>" . "<input type=hidden name=hidden value=" . $record['ItemNumber'] . " </td>";
	echo "<td>" . "<input type=submit name=update value=update" . " </td>";
	echo "</form>";

echo "</table>";



Open in new window

Scott Johnston
Scott Johnston
1 Solution
Dave BaldwinFixer of ProblemsCommented:
Just add another <td> to your table with the timestamp field.  It would be similar to the ones you already have.
Brian TaoSenior Business Solutions ConsultantCommented:
1. Please provide the table definition
2. IMPORTANT!!: in your row #16 where you have $UpdateQuery, there's no WHERE clause.  It will update your entire table.
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Scott JohnstonSystems ConsultantAuthor Commented:
Brian....Yes, i noticed that last night.  I'm reworking the code since this is inherited code.
I was able to create the form and I got the data and time stamp to be displayed in my browser correctly.  I'm working with someone elses code and find in some case it is better to start from scratch.  This may be one of those situations.

WHen I do a select query I am able to have the Date and time stamp display perfectly.

Select query results
Since I got the select query to work, i will be working on a lookup and then a update.

Thank you

I appreciate everyone coments and will distribute points
Scott JohnstonSystems ConsultantAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 400 points for Brian Tao's comment #a40604649
Assisted answer: 100 points for Ray Paseur's comment #a40605388
Assisted answer: 0 points for skcbd's comment #a40606223

for the following reason:

Thannk you pointed me the right direction.
FOund I had to do some new coding and was able to repair the sitautoin
Scott JohnstonSystems ConsultantAuthor Commented:
After reviewing coment about my question, i resolved by re-writing my code, thought that that should be part of the solution
Brian TaoSenior Business Solutions ConsultantCommented:
Glad that I could help.  Thanks for the points.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now