HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
array, datetime data type
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
raninda



Joined: 10 Apr 2008
Posts: 11

PostPosted: Tue May 27, 2008 5:25 pm     array, datetime data type Reply with quote

hi,
i have table (phpmysql) named 'guestbook' and there is a field name 'guestdate' data type is datetime.

i have this code to print the field 'guestdate'

Code:

<?php
include "db.php";
   $query=mysql_db_query($dbname, "SELECT `guestdate` FROM `guestbook` WHERE `id_guest` =42");
   $row=mysql_fetch_row($query);
   if(!$row)
      print("<font size='1' face='Verdana'>no rows</font>");
   else
   {   
      print"$guestdate"; //result Array supposed to be 2008-05-27 06:05:13
   }
?>


i guess its because datetime datatype. so when i click the button, only word 'Array' written.
i think i have to separate it using explode() function or array_slice() function. but it won't work.
i already check the sql too, and it work. so the problem not in the sql.please, if anybody can give advice.many many thanks.
thexpgeek



Joined: 13 Dec 2007
Posts: 24

PostPosted: Wed May 28, 2008 10:30 am     Reply with quote

I used the following to get a list of usernames contained in a table. You should be able to modify it to get what you need from it.

Code:
<form method="post"target="_self">
<?php
include 'connect.php';
mysql_connect($hostname,$username,$password) or die(mysql_error());
mysql_select_db(elnods) or die(mysql_error());
$sqlchar = "SELECT `character` from `tbl_stats`";
$resultchar = mysql_query($sqlchar);
echo "<Select Name=\"charactername\">";
echo "<Option Value=\"$character\">$character</Option>";
echo "<Option Value=\"------------\">------------</Option>";
echo "<Option Value=\"\"></Option>";
while($c=mysql_fetch_array($resultchar)){
   echo "<Option Value=\"$c[character]\">$c[character]</Option>";
}
mysql_close();
echo "</select>";
?>
<input type='submit' name='submit' value='Show Stats'>
</form>
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial