I am having trouble getting this to work. I have been able to call data from a dropdown menu and place it into a table and have it actively update without reloading the page. I am now trying to get the database information that is called to appear within a text input field or another drop down menu.
So basically I have a drop down menu that will call up user information, I am trying to get that information that is called to appear within another form so I can update it. Here is the code I am working with;
table7.php
Person info will be listed here.
getuser2.php
$q = intval($_GET['q']);
$con=mysqli_connect("localhost","user","password","database");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT * FROM users WHERE id = '".$q."'";
$result1 = mysqli_query($con,$sql);
echo "
Username
E-Mail
Info 1
";
echo "";
echo "
";
mysqli_close($con);
?>
Within the getuser2.php code if you strip out the form input section and replace it with a call for uname using the format directly below for email and info it will display the data called from the database in standard text format.
However, I am encountering this error:
Parse error: syntax error, unexpected 'text' (T_STRING), expecting ',' or ';' in C:\wamp\www\getuser2.php on line 25
Answer
The problem is the following:
echo " ";
You have double quotes inside a double-quoted string. PHP doesn't know where the string ends.
An easy fix (since you're not using variables inside the string anyway) is to change the double quotes to single quotes:
echo ' ';
No comments:
Post a Comment