Discussion:
show data on the text input box
iccsi
2014-05-09 04:37:41 UTC
Permalink
I have following code to connect MySQL and database.
I see 'connected to database',

I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,


Regards,


Iccsi,




<?php

/*** mysql hostname ***/
$hostname = 'MyHost';

/*** mysql username ***/
$username = 'MyUser';

/*** mysql password ***/
$password = 'password';

try {
$dbh = new PDO("mysql:host=$hostname;dbname=iccsimd", $username,
$password);
/*** echo a message saying we have connected ***/
echo 'Connected to database';
}
catch(PDOException $e)
{
echo $e->getMessage();
}


$result = mysql_query("SELECT invid, invdate, note, amount FROM invheader");

//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
echo "ID:".$row{'invid'}." Inv Date:".$row{'invdate'}."Note: ". //display
the results
$row{'Note'}."<br>";
}
//close the connection
mysql_close($dbh);


?><br />


<body>
<table width="200" border="1">
<tr>
<td><input name="mytext" type="text" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Robert Cummings
2014-05-09 06:13:28 UTC
Permalink
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?

<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-09 22:12:18 UTC
Permalink
Thanks for the information and help,

I use the following code to show data, but it shows '/', but not data.

<td><input name="mytext" type="text" value=<?php echo ($row['invdate']); ?>
/></td>

Are there any way to access from mySQL result data?
Thanks again for helping,

Regards,


Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?

<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-05-09 22:19:41 UTC
Permalink
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
type and read:
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-09 22:54:54 UTC
Permalink
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of
file?

Thanks again,

Regard,


Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
type and read:
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jasper Kips
2014-05-09 23:06:21 UTC
Permalink
Hi,

No you write it like this:
<td><input name="mytext" type="text" value="<?php echo ($row['invdate']); ?>” /></td>

So quotes arounde the <?php block. Do not escape them with a \

Go on you are doing great.

Sincerely,
Jasper
I tried both with '\' or without '\', but I do not see the data on the text box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-05-09 23:08:40 UTC
Permalink
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-09 23:25:51 UTC
Permalink
Here is full code,
Thanks again for helping,

Regards,

Iccsi,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>

</tr>
<?php

$hostname = "localhost";
$username = "root";
$password = "password";

try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username,
$password);

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}

$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from
invheader');

while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}

?>
</table>
</td>
</tr>
</table>
</body>
</html>
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ken Robinson
2014-05-09 23:47:22 UTC
Permalink
Here's my re-work of your code. I moved the PHP section to the start
of the file & stored the output needed in a temporary array, which is
output in the correct place.

The reason that this line:
<input name="mytext" type="text" value="<?php echo ($row['invdate']); ?>" />
doesn't show anything is that there is no data in $row at that point.

<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new
PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$tmp = array();
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$tmp[] = "<td>";
$tmp[] = "<input name='mytext' type='text'
value='{$row['invdate']}' />";
$tmp[] = "</td>";
$tmp[] = "{$row['invid']} {$row['invdate']}
{$row['client_id']} {$row['amount']"; //etc...
}
?>
<!DOCTYPE html>
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<?php echo implode("\n",$tmp) . "\n"; ?>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>


Ken
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8",
$username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from
invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-10 00:30:10 UTC
Permalink
Thanks a million for helping,

I have to remove the following line in the file to make it shows data.

$tmp[] = "{$row['invid']} {$row['invdate']} {$row['client_id']}
{$row['amount']"; //etc...

In my Dreamweaver, it shows syntax error. I got HTTP 500 when I have this
line in file.

I guess that if I want to display more than one field then I just need to
have another array or any other method to do so,

Thanks again for your helping,

Regards,

Iccsi,



"Ken Robinson" wrote in message news:***@pb1.pair.com...

Here's my re-work of your code. I moved the PHP section to the start
of the file & stored the output needed in a temporary array, which is
output in the correct place.

The reason that this line:
<input name="mytext" type="text" value="<?php echo ($row['invdate']); ?>" />
doesn't show anything is that there is no data in $row at that point.

<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new
PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$tmp = array();
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from
invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$tmp[] = "<td>";
$tmp[] = "<input name='mytext' type='text'
value='{$row['invdate']}' />";
$tmp[] = "</td>";
$tmp[] = "{$row['invid']} {$row['invdate']}
{$row['client_id']} {$row['amount']"; //etc...
}
?>
<!DOCTYPE html>
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<?php echo implode("\n",$tmp) . "\n"; ?>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>


Ken
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username,
$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-10 00:34:49 UTC
Permalink
I got it works now,
I just put a curly bracket in the end of the line,

Thanks a million again for helping,


Regards,


Iccsi,

"Ken Robinson" wrote in message news:***@pb1.pair.com...

Here's my re-work of your code. I moved the PHP section to the start
of the file & stored the output needed in a temporary array, which is
output in the correct place.

The reason that this line:
<input name="mytext" type="text" value="<?php echo ($row['invdate']); ?>" />
doesn't show anything is that there is no data in $row at that point.

<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new
PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$tmp = array();
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from
invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$tmp[] = "<td>";
$tmp[] = "<input name='mytext' type='text'
value='{$row['invdate']}' />";
$tmp[] = "</td>";
$tmp[] = "{$row['invid']} {$row['invdate']}
{$row['client_id']} {$row['amount']"; //etc...
}
?>
<!DOCTYPE html>
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<?php echo implode("\n",$tmp) . "\n"; ?>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>


Ken
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username,
$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ken Robinson
2014-05-10 00:43:29 UTC
Permalink
Good.

I don't always error check my code.

While developing, you should be running with errors displayed. The
500 error was caused by PHP dying on the error. If you had errors
showing, that error would have been shown to you.

Ken
Post by iccsi
I got it works now,
I just put a curly bracket in the end of the line,
Thanks a million again for helping,
Regards,
Iccsi,
Here's my re-work of your code. I moved the PHP section to the start
of the file & stored the output needed in a temporary array, which is
output in the correct place.
<input name="mytext" type="text" value="<?php echo ($row['invdate']); ?>" />
doesn't show anything is that there is no data in $row at that point.
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new
PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$tmp = array();
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$tmp[] = "<td>";
$tmp[] = "<input name='mytext' type='text'
value='{$row['invdate']}' />";
$tmp[] = "</td>";
$tmp[] = "{$row['invid']} {$row['invdate']}
{$row['client_id']} {$row['amount']"; //etc...
}
?>
<!DOCTYPE html>
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<?php echo implode("\n",$tmp) . "\n"; ?>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Ken
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8",
$username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-10 18:09:26 UTC
Permalink
Thanks a million for the information and help,
Do I need to store data in to an array before show on the form all the time?
As you mentioned that there is no data at the point on the html form, should
it resolve the issue move php code before the html code?
I think it should be a way to show data on the form using SQL or sored
procedures return data.

Thanks again for the information and help,


Regards,


iccsi,

"Ken Robinson" wrote in message news:***@pb1.pair.com...

Good.

I don't always error check my code.

While developing, you should be running with errors displayed. The
500 error was caused by PHP dying on the error. If you had errors
showing, that error would have been shown to you.

Ken
Post by iccsi
I got it works now,
I just put a curly bracket in the end of the line,
Thanks a million again for helping,
Regards,
Iccsi,
Here's my re-work of your code. I moved the PHP section to the start
of the file & stored the output needed in a temporary array, which is
output in the correct place.
<input name="mytext" type="text" value="<?php echo ($row['invdate']); ?>" />
doesn't show anything is that there is no data in $row at that point.
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new
PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$tmp = array();
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$tmp[] = "<td>";
$tmp[] = "<input name='mytext' type='text'
value='{$row['invdate']}' />";
$tmp[] = "</td>";
$tmp[] = "{$row['invid']} {$row['invdate']}
{$row['client_id']} {$row['amount']"; //etc...
}
?>
<!DOCTYPE html>
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<?php echo implode("\n",$tmp) . "\n"; ?>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Ken
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username,
$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Post by iccsi
I tried both with '\' or without '\', but I do not see the data on the text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
What does your full code look like now?
Post by iccsi
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jasper Kips
2014-05-09 23:09:22 UTC
Permalink
Oh, and try this after you get the row:

$out_data=print_r($row, true);
error_log($outdata);

If you can access the error log that is. It helps you to inspect the data you get from the database.

Sincerely Jasper
I tried both with '\' or without '\', but I do not see the data on the text box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-10 18:10:48 UTC
Permalink
Thanks for the information and help,

Regards,


iccsi,




"Jasper Kips" <***@planetkips.nl> wrote in message news:7E50771E-F538-40D1-982D-***@planetkips.nl...
Oh, and try this after you get the row:

$out_data=print_r($row, true);
error_log($outdata);

If you can access the error log that is. It helps you to inspect the data you get from the database.

Sincerely Jasper

Op 10 mei 2014, om 00:54 heeft iccsi <***@gmail.com> het volgende geschreven:


I tried both with '\' or without '\', but I do not see the data on the text box on both situation.
Do I need fetch records using php or how do I know that it is not end of file?

Thanks again,

Regard,


Iccsi,


"Jim Giner" wrote in message news:***@pb1.pair.com...

On 5/9/2014 6:12 PM, iccsi wrote:

Thanks for the information and help,

I use the following code to show data, but it shows '/', but not data.

<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>

Are there any way to access from mySQL result data?
Thanks again for helping,

Regards,


Iccsi,



"Robert Cummings" wrote in message news:***@interjinn.com...

On 14-05-09 12:37 AM, iccsi wrote:

I have following code to connect MySQL and database.
I see 'connected to database',

I would like to know that which code do I need to show my data on the
text
box?
Your help and information is great appreciated,



Do you mean like the following?

<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />

Cheers,
Rob.


You have no quotes on your value clause. Plus this might be easier to
type and read:
<?
echo "<td><input name='mytext' type='text' value='{$row[\'invdate\']}'>";
?>
(Not sure you need the \ inside the [] on the $row reference, but I put
them there.)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-05-09 13:54:23 UTC
Permalink
Post by iccsi
echo "ID:".$row{'invid'}." Inv Date:".$row{'invdate'}."Note: ".
$row{'Note'}."<br>";
These are wrong. You are processing an array of the results. Arrays
are referenced with brackets, not braces. Should read:

echo "ID:".$row['invid']." Inv Date:".$row['invdate']."Note:
".$row['Note']."<br>";
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-09 22:15:04 UTC
Permalink
Thanks a million for the information and help,

Regards,


Iccsi,
Post by iccsi
echo "ID:".$row{'invid'}." Inv Date:".$row{'invdate'}."Note: ".
$row{'Note'}."<br>";
These are wrong. You are processing an array of the results. Arrays
are referenced with brackets, not braces. Should read:

echo "ID:".$row['invid']." Inv Date:".$row['invdate']."Note:
".$row['Note']."<br>";
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Domain nikha.org
2014-05-10 19:54:30 UTC
Permalink
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username,
$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from
invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
I tried both with '' or without '', but I do not see the data on the
text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of
file?
What does your full code look like now?
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo ($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the
text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row['invdate']}'>";
?>
(Not sure you need the inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
My dear,

your while-loop stops with an empty value - that's the terminating condition!
And exactly this is shown in your input tag: nothing!

You must fetch the values while the loop is running!

Greatings, Niklaus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
iccsi
2014-05-10 20:37:36 UTC
Permalink
Thanks for the information and help,

do you mean that I need to do something like following in the loop?

$result = $sth->fetchAll(PDO::FETCH_CLASS, "fruit");
var_dump($result);

thanks again, I am pretty new to PHP.

Regards,

Iccsi,
Post by iccsi
Here is full code,
Thanks again for helping,
Regards,
Iccsi,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>
<input name="mytext" type="text" value="<?php echo
($row['invdate']); ?>" />
</td>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "password";
try {
$dbh = new PDO("mysql:host=localhost;dbname=mydb;charset=utf8", $username,
$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
echo "Connected to database";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $dbh->query('SELECT invid, invdate, client_id, amount from
invheader');
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['invid'].' '.$row['invdate'].' '.$row['client_id'].'
'.$row['amount']; //etc...
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
I tried both with '' or without '', but I do not see the data on the
text
box on both situation.
Do I need fetch records using php or how do I know that it is not end of
file?
What does your full code look like now?
Thanks again,
Regard,
Iccsi,
Post by iccsi
Thanks for the information and help,
I use the following code to show data, but it shows '/', but not data.
<td><input name="mytext" type="text" value=<?php echo
($row['invdate']);
?> /></td>
Are there any way to access from mySQL result data?
Thanks again for helping,
Regards,
Iccsi,
Post by iccsi
I have following code to connect MySQL and database.
I see 'connected to database',
I would like to know that which code do I need to show my data on the
text
box?
Your help and information is great appreciated,
Do you mean like the following?
<input name="mytext" type="text" value="<?php echo htmlspecialchars(
$value ); ?>" />
Cheers,
Rob.
You have no quotes on your value clause. Plus this might be easier to
<?
echo "<td><input name='mytext' type='text' value='{$row['invdate']}'>";
?>
(Not sure you need the inside the [] on the $row reference, but I put
them there.)
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
My dear,

your while-loop stops with an empty value - that's the terminating
condition!
And exactly this is shown in your input tag: nothing!

You must fetch the values while the loop is running!

Greatings, Niklaus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...