Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it,
there are some things with which I am confounded!
What I'm trying to do is read in a Date from a mySql database and then
display it on screen (the Date is in the usual yyyy-mm-dd format).
If I use SQL on phpadmin
SELECT Date
FROM details
WHERE details.Name = "Paul Lee"
LIMIT 0 , 30
The result comes up 2005-01-01, so this seems to work.
But if I use the following:
$db = mysqli_connect("localhost","root","");
@mysqli_select_db($db, "personnel") or die ( "Unable to select
database" );
$query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee"
LIMIT 0, 30'
$result=mysqli_query($db, $query);
echo "<br>";
echo $result;
mysqli_close($db);
I get "Object id #2" displayed on screen.
I have tried to use the explode function to separate the months, year
and day using the "-" as a delimeter, but this doesn't work, and I
can't seem to get the other php date/time functions to work either.
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Displaying DATE From Database?
I have a database field called `DATE` which has data type date. The purpose of `DATE` as you guessed is to store a date. 2007-11-31 I want to write a script to update a news article posting date. The only way to do this is to break DATE into three separate sections, $year, $month and $day How do I go about doing this? Please keep in mind, the date is already stored in the database, it does not need to be today's date. It can be any date! Lets work with 2007-11-31 as an example.
View Replies !
View Related
Reading From A Mysql Database
i have made a script that takes information from a form and adds it to a database. it then displays the data the that was placed into the form with the $_POST[''] function. however, i want it to read off the data that was placed into the form, add it to a database, then in another file ("process.php"), the data will be read STRAIGHT from the database and NOT from the POST function. can anyone help me, this is my code: <?php $con = mysql_connect("localhost","USERNAME","PASSWORD"); if (!$con)   {   die('Could not connect: ' . mysql_error());   }mysql_select_db("DATABASE", $con);$sql="INSERT INTO registration (nickname, password, email) VALUES ('$_POST[nickname]','$_POST[password]','$_POST[email]')";if (!mysql_query($sql,$con))   {   die('Error: ' . mysql_error()); ..................
View Replies !
View Related
Date Is Not Being Pulled From MYSQL Database, Instead Current Date Is Displayed!
I am having trouble pulling a date from a database using PHP at the <a href="http://www.mytuneslive.com/ameshkin69/"> following page.</a> Here is the code. As you can see, it is just making the date the current time. The values in the database are UNIX timestamp, and the DATE() function is used to convert from UNIX to readable date. Can <td width="55%" align="left" valign="top"><?php $row_comment['timestamp'] = date("n d Y g:i A");.....
View Replies !
View Related
Date Displaying And Storing In MySQL While In Wrong Timezone
I've only used php to display the current date but I can see that I'm not in the same timezone as the server is. Its 5 hours ahead and I can't get it to show the date as Eastern Time. I'm developing a site for a non-profit slopitch league so they can submit score sheets and track their season. 2 teams must submit a score sheet for their team within 72 hours of having played the game. Then they are not allowed to enter the score sheet without the administrator's permission. Code:
View Replies !
View Related
Displaying Block Of Text From MySQL Database
I would like to create a details.php page that displays all my products. I understand how to get the title, price, description etc from mySQL. But my problem is how do I get a list of data? For example say I want to display the features of a product in point form (list). What is the best way to do this? How do most common websites do this? Code:
View Replies !
View Related
Problem Displaying A Mysql Database Field
I have a varchar field in a MySQL database that contains a line of text like so: "This is a line if text" The double quotes are included in the database field. I cannot seem to display it on my HTML page, it always shows as blank. I have tried using both the stripslashes() and the html_entity_decode() but it still shows as blank. An code example I am trying is as follows: <?php echo stripslashes(html_entity_decode($my_variable_from_ a_mysql_database)); ?> How can I display this please?
View Replies !
View Related
Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:
View Replies !
View Related
Get A Date To Insert Into My Mysql Database
How do I get a date to insert into my mysql database. I just want a date to be inserted when a user hits the submit button on the form. The user doesnt input a date, i assume it gets the date from the server. also what is the correct sql to set up the field in my table. I have looked at the sql help but cant seem to work it out. I currently have field name: date type: date null: not null default: 0000-00-00
View Replies !
View Related
Store A Download Date In A MySQL Database
I need to store a download date in a MySQL Database when a user makes an order,and check to see if that download date has expired when the user logs in in the future. What would be the best way to do this? timestamp? Is there a PHP function that can anaylze the timestamp (or some sort of date string) and check to see how much time is left? Example: User orders download access for 24 hours - Comes back 5 hours, 20 minutes later - It should tell him that he has 18 hours fourty minutes left.
View Replies !
View Related
Pulling Data From A MySQL Database With PHP Date Code??
I am trying to find ways to retrieve data by date from a mysql database. What I would like to do is to have the option for people to retrieve a file that was entered in the week before the current day (something like click here for all drinks added in the last week) I have tried to make this code work, the only way I can is to manually change the date every day, I would like it to do it automatically.
View Replies !
View Related
Reading Cookie Expiry Date
Is it possible to read the expiry date of a cookie? The following only returns the value of the cookie: echo $_COOKIE['somecookie']; I wasn't able to find out from the manual if $_COOKIE is a multidimensional array from which keys other than the name can be read. The purpose would be to be able to tell a user when a certain cookie will expire.
View Replies !
View Related
Displaying Date
i'm working on K Yank's book and, at some point, i've an insert like this: $sql = "INSERT INTO Jokes SET ... JokeDate = CURDATE()"; When i dysplay this on my webpage, the date format is YYYY,MM,DD and in my country (Portugal), the format is day, month, year How can i achieve it?
View Replies !
View Related
Displaying Date...
As a final touch to my current project I am trying to display a "Last Updated: " field on the user profile pages of the website. The SQL database is updating the field last_updated automatically any time a record is altered, and this is working fine... Structure details from phpMyAdmin (in table 'users'): last_updated timestamp ON UPDATE CURRENT_TIMESTAMP No 0000-00-00 00:00:00 However when I try to output this date I get the result: Profile Updated: January 1, 1970 The code I am using is as follows... Code:
View Replies !
View Related
Displaying A Date
My current code: foreach ($page['events'] as $z) { echo '<b>', $z['date'], '</b></p>'; } Which is pulling "date" from a DATE field in the database. Would like it to display as 3-22-2007 ... instead of 2007-3-22 - I know theres a quick answer out there but cant find it.
View Replies !
View Related
Displaying A Date Range
I would like to display a user specified date range e.g Monday to Monday next week or maybe Monday next month. When I have the basic function worked out I would like to get Data from a Mysql Database. here is what I have thought about. Code:
View Replies !
View Related
Displaying A Date With Strtotime
I have successfully used strtotime to format the date on a webpage that is pulled form a MySQL database in the form yyyy-mm-dd. However, in another part of the webpage, I have to insert another date that may contain a NULL entry in the database. If I use strtotime to format this then it enters the current date, whereas I want it left blank.
View Replies !
View Related
Displaying A Date Before 1970
I am really struggling with displaying a date PRE 1970 in php and mysql. I have a date of birth field in my myqsl db and can echo it out without problem but because i need to echo it out in UK format (DD-MM-YYYY) I get 31 December 1969 on all dated previous to this date. This is the code I use to 'switch' the date around list($year, $month, $day)= explode("-", $date); $show_date=date(" d F Y", mktime(0,0,0,$month,$day,$year));
View Replies !
View Related
Displaying Date/time
I'd quite like to have a list of dates/times showin in different timezones i.e. China: 09:56:01PM, saturday 5 Feburary India: 01:56:01AM, saturday 5 Feburary Is there anyway I an do this on the fly using PHP without having to change any sort of timezone/server config variables?
View Replies !
View Related
Database Reading..
I have a mysql database named userdata setup. like this Database = userdata Under userdata are the columns buddy and username what i want to do is make a page that has a textbox with a button on it that says view data. when you type one of the usernames in the textbox then you would hit view data. when view data is hit. it will search the database for every row in the column username that = textbox then display all of the rows it found .
View Replies !
View Related
Displaying Modified Date Of A URL File
I want to display a web page with links to various documents and display the date each document was last modified next to the link. I've found the filemtime command and that works quite nicely for "local" files. However, filemtime doesn't work if the file(s) are refered to by their URLs (which is how I need to do it). A comment on the manual page (http://www.php.net/manual/function.filemtime.php3) refers to having to use "Socket Operations" but the link posted with that comment doesn't work (it just goes to a page saying the website has been rearranged).
View Replies !
View Related
Date/time Displaying Wrong
How do I set the time display to echo the time, in the timezone the user is in and not the server time. For somereason im in eastern timezone and the host server i9s in central and the time displayed on my laptop is in central.
View Replies !
View Related
Displaying The Latest Submitted Date
I have a MySQL database with one table containing users who submit info and this is tagged to the country they're from. The query below, will list a table GROUPED according to the country and displaying the number of entries in each country. Eg: Austria - 2 Australia - 10 I am looking into the possibility of displaying the latest date from the table. For example: Two users in Australia submitted entries on 1 October and 10th October. So the "Last Date Submitted" should show, 10th October under Australia. $list_countries = mysql_query("SELECT country, date_format(date, '%M %d, %Y') AS date, count(country) AS num_of_entries FROM table GROUP BY country") Btw, each entry has its uniqueID too. How do I display the latest date when GROUPING?
View Replies !
View Related
Displaying Date - Show Dd-mm-yyyy
Having set up some info in my database. I wanted to display the date the information was posted. Entering the data into the database the date displays in the format yyyy-mm--dd. How does one go about changing this to show dd-mm-yyyy or even something like 9-sept-05?
View Replies !
View Related
Reading Database Problem
I'm having a problem reading the database. But I assume its due to the fact that I have done some very bad coding lol... I'm still fairly new. So forgive me. A little info... I'm trying to set up a so called counter. When someone opens a page it will check to see if someone has been to the site before and if they have it will add a 1 to visits. And if the person hasn't been to the site before it will insert their ip along with 1 visit to the database. As you can see this is being done by reading the persons ip address. But instead of updating an ip address with visits... It keeps inserting and inserting. Never updating.. Code:
View Replies !
View Related
Reading Database From Another Site
is it possible to read a database from another site without using javascript or vbscript? site1 gives data to site2 site2 display data from site1 something that works like rss? (i don't know how to create this kind of script.) My purpose is to integrate my two websites, the first website will supply the information needed then the second site will diplay the information on certain locations of the site. I already learned how to read/display/manipulate mysql data if the database is located on the same host (server) but not on a separate host.
View Replies !
View Related
Reading String From Database
I have a field in a database that can hold either a link to an image e.g. photos/image1.jpg or a number e.g. 555-1212. I need our php script to tell the difference between the two. If it is a link, it needs to display the image. If it is a number, it should display the number. Any ideas on how to do this?
View Replies !
View Related
Compare Date Of Today And The Date In The Database
i have a db that stores a date in a table with a specific column. db=test table=test_date_compare column name=date_inserted ok i hv a php form that allows user to input date and it enters in the above column (date) as in format eg: 21/03/2007 now i wat i would like to do is i would like to compare date of today and the date in the database if it is lesser then todays date it deletes that row of data. deleting the row of data i know how but the problem comes wen coparing the date i dunno how to ...
View Replies !
View Related
Converting Database Date To Normal Date
I am looking for a way to convert a date that is stored in a MySQL database like this after useing the date() function in PHP: 2006-08-16 21:03:54 and convert it into a date this: 16 August 2006 @ 11:03:54pm Does anyone have some insight as to how I would go about doing that?
View Replies !
View Related
Displaying 'new' Icon Based On Date?
I'd like to display a little "new" icon next to all products in a directory which are, funnily enough, new! I've got a date (timestamp) for each product which is inserted on adding a new product and updating a product. I'd like to do a conditional region using the timestamo but I'm not sure what to use - I could do === [current date] but that would only show the icon for that day and I'd like it to be there for about a week or so.
View Replies !
View Related
Displaying Local Date In Specific Format
i'm trying to decide whether to use PHP or JavaScript to display a date on a website. what i'm wondering is where does PHP take the date from, the server or the client (ie will timezone become a factor). aswell as this, is there a simple way to allow the date to be displayed as: "22nd" "1st" or "14th" instead of "22" "1" or "14"?
View Replies !
View Related
Reading Tab Delimited File Into Database
I have a .tab file that I need to write to the database. I've read it in, but for some reason it's not reading correctly. I'm truncating the complete database and then reloading it with whatever is in the tab file. I keep getting an error when trying to run my current code which is: Code:
View Replies !
View Related
Reading Composite Values In Database
i have three table codes -------------it conatins post codes of different regisons day-------------------------it contains the day on which delivery can be made e,g post code 44444 will be served on mon , tue or day 1 day 2 time--------------------it contains the time on which delivery will be made on certain days e,g on monday time is 2-5 , 6-9 , 11-12 and so on now i want to display all data in the form of report but i don't know how to do it.
View Replies !
View Related
Can't Figure Out A Problem Reading From Database...
what's wrong with this code? <?php $sql = "SELECT * FROM booked"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { if($caldate == $row['date']){ echo " style="color:#000000; background-color:#808080""; } } }else{ echo ">not found!</td>"; exit; } }else{ echo ">" . mysql_error() . "</td>"; exit; } ?> every time I run it I receive the "not found!" error, which means it can't find any rows in the table booked. I know for a fact there are 143 entries in that table... I've quadrouple checked the table name and the row name.. but no luck.
View Replies !
View Related
Reading Barcode, Updating Access Database
I am writing a tracking system using barcode readers. I have a simple page with two entry points, one to display the form to receive a scanned serial number and the other to do the upload to an Access database. It works okay with a button on the upload screen to return to the form screen but I want to return to the form screen without an OnClick event handler. Basically, I want the user to see the "Enter serial Number" prompt and be able to do scan after scan without having to click on anything else. I need to display the status of the upload after each scan. I have tried using windows.location.href, header(location:etc) , $PHP_SELF etc but without any success. Can anyone help with syntax to reload or load the page (including entry point and status variables) after the database is updated without the user having to do any clicking? Or is this best handled in Javascript?
View Replies !
View Related
Reading An MS Access Database File On *NIX Platform Using PHP
I'm building a small web application for a friend using PHP. He'd like to use MS Access to keep the data in, and update the data on the site by FTP'ing Access files he edits on his machine up to the web host. The web host is unix-based (FreeBSD, slightly hacked by Verio, I believe), so this means COM functions aren't available. ODBC was my next thought, but I've never used it, and there are a few things I don't understand. Setting up a DSN is one of them -- apparently this isn't as simple as constructing a string, and all the tutorials I can find seem to involve going into a Windows control panel and making a setting. This of course will not be possible, since there are no windows control panels on FreeBSD. Can anyone offer any quick tips on how to use the odbc database functions or PEAR::DB to query data from an MS Access file sitting on a UNIX box?
View Replies !
View Related
|