Hi.
Let's suppose we have a table with many records like this :
CREATE TABLE ARTICLE (
ID INTEGER NOT NULL
, NAME TEXT NOT NULL
, CONTENT TEXT NOT NULL
, SOURCE TEXT
, ARTDATE DATE
, HITS INTEGER DEFAULT 0
, PRIMARY KEY (ID)
)TYPE=InnoDB;
I want to execute the following query: SELECT NAME,CONTENT,SOURCE,ARTDATE FROM ARTICLE WHERE ID=[some_valid_id ]
CONTENT and SOURCE are usually fields with text of many lines.
So I execute this code:
$sql="SELECT NAME,CONTENT,SOURCE,ARTDATE FROM ARTICLE WHERE ID=".$_POST['id'];
$connection=mysql_connect('localhost', 'root', '');
mysql_select_db ('DATABASE',$connection);
$result=mysql_query ($sql, $connection);
$vectorResult=mysql_fetch_array($result);
$name=$vectorResult['NAME'];
When I do 'echo $name', or 'echo $vectorResult['NAME']' it just works fine (the query has been executed), but when I want to to the following it just won't do anything:
echo "<form name=form_retrieve action=update.php method=post>";
echo "<input name=name_art type=text size=40 width=35 maxlength=35 value=".$name." >";
echo "<textarea name=contenido cols=100 rows=12 value=".$vectorResult['CONTENT']." >";
echo "<input name=fecha type=text size=10 maxlength=10 value=".$vectorResult['ARTDATE']." >";
echo "</form>";
I'm trying to display the data from the database on a form.
The best I could is to assign and display the first 4 chars of the whole string of "$name" in the value attribute, but that's it.
So I'm not sure how to retrieve the fields from MySQL to the value on the form.
Please help!