Solved

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

Posted on 2015-02-11
7
233 Views
Last Modified: 2015-02-13
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
<html>
<head>
</head>
<body>
	<?php
$con = mysql_connect("domain.com","account","passowrd");
 // Check connection
 if (!$con) {
   die ('Could not Connect to MySQL: ' . mysql_error());
 }

mysql_select_db("database",$con);


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>
<tr>
<th> Item Number </th>
<th> Starting Date / Time </th>
<th> Ending Date / Time </th>
<th> Sale Price </th>
</tr>";
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>";
mysql_close($con)

?>

</body>
</html>

Open in new window

0
Comment
Question by:Scott Johnston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40604612
Just add another <td> to your table with the timestamp field.  It would be similar to the ones you already have.
0
 
LVL 9

Accepted Solution

by:
Brian Tao earned 500 total points
ID: 40604649
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.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40605388
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:Scott Johnston
ID: 40606223
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
0
 

Author Comment

by:Scott Johnston
ID: 40606304
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
0
 

Author Comment

by:Scott Johnston
ID: 40606296
After reviewing coment about my question, i resolved by re-writing my code, thought that that should be part of the solution
0
 
LVL 9

Expert Comment

by:Brian Tao
ID: 40607752
Glad that I could help.  Thanks for the points.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question