0

can some tell me what's wrong i tried putting the $date in my textfield from my MySQL. can someone pls correct my code :) thanks

<?php
$username="root";
$password="";
$database="dbdate";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT *
FROM `cdate`
WHERE 1
LIMIT 0 , 30";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
	echo $row['date'];
	}
?>

<input name = "date"  value="<? echo $row['date']; ?>" type="text" />
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by katarey
0

I am not sure what actually you wanna do but hope fully this may help,

1st problem: localhost is not in "" (quots)

that should be like this
mysql_connect("localhost",$username,$password);

2nd:
<input name = "date" value="<? echo $row; ?>" type="text" /> is out side of loop so that $row have no value in it
see this, this will print multiple(according to the database records)input fields with date values in it

<?php
$username="root";
$password="";
$database="dbdate";

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT *
FROM `cdate`
WHERE 1
LIMIT 0 , 30";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
	//echo $row['date'];
	echo "<input name = \"date\"  value=\"" . $row['date'] . "\" type=\"text\" /> <br /> <br />";
}
?>

or

<?php
$username="root";
$password="";
$database="dbdate";

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT *
FROM `cdate`
WHERE 1
LIMIT 0 , 30";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result)
?>
<input name = "date"  value="<?php echo $row['date']; ?>" type="text" />

Edited by katarey: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.