mb326 Posted April 14, 2008 Share Posted April 14, 2008 Hi, I can't appear to find a tutorial or any posts to do this, but I'm trying to access values from an SQL Database and display them in the fields of a HTML form. What I've initially tried doesn't work and echoes an 'unexpected T_STRING variable, in the bold line of the form code below. Please can anyone give me some guidelines? // query to retrieve value from posted variable $eventID = $_POST['EventID']; $query = mysql_query($database, "SELECT * FROM EventCalendar WHERE eventID = $eventID"); $getData = mysql_fetch_object($query); $content = '<div class =\"section\"><H1>Change Event Details</H1>\n'; $content .= '<form action="changeSuccessful.php" method="post">'; [b]$content .= '<p> Location <input type="text" name="$_GET['$getData->location']" size="20"/> </p>';[/b] Link to comment https://forums.phpfreaks.com/topic/101115-posting-values-from-an-sql-database-onto-a-html-form/ Share on other sites More sharing options...
BlueSkyIS Posted April 14, 2008 Share Posted April 14, 2008 ...is invalid, should be something more like: // query to retrieve value from posted variable $eventID = $_POST['EventID']; $query = mysql_query("SELECT * FROM EventCalendar WHERE eventID = '$eventID'") or die(mysql_error()); $getData = mysql_fetch_array($query); $content = '<div class =\"section\"><H1>Change Event Details</H1>\n'; $content .= '<form action="changeSuccessful.php" method="post">'; $content .= "<p> Location <input type='text' name='{$getData['location']}' size='20'/> </p>"; I suggest using single quotes inside HTML elements. Link to comment https://forums.phpfreaks.com/topic/101115-posting-values-from-an-sql-database-onto-a-html-form/#findComment-517138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.