Answer the question
In order to leave comments, you need to log in
Output from db to textarea?
Hello! I need to output from the database to the textarea, what's wrong?
<?php $db = mysql_connect('localhost', 'webrazm1_test', '901kiril');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
mysql_select_db('webrazm1_test')
or die('Could not select database:'.mysql_error());
$result=mysql_query('SELECT column FROM `main_text`');
while($row=mysql_fetch_array($result))
{echo 'Текст<br><textarea name='main_text' id='main_text' cols=37 rows=5>".$row['main_text']."</textarea>';};
mysql_close($db)
or die('Could not close connection'); ?>
doesn't work, what's wrong?
Answer the question
In order to leave comments, you need to log in
The visual editor highlighted you.
Syntax error
need something like this:
{echo "Текст<br><textarea name='main_text' id='main_text' cols=37 rows=5>".$row['main_text'].'</textarea>';}
It is obvious that you have crap with quotes, I would recommend:
firstly, read about quotes in PHP (this also applies to Mikhail);
secondly, instead of constructing
while($row=mysql_fetch_array($result)){
echo 'Текст<br><textarea name='main_text' id='main_text' cols=37 rows=5>".$row['main_text']."</textarea>';};
while($row=mysql_fetch_array($result)){ ?>
Текст
<br>
<textarea name='main_text' id='main_text' cols=37 rows=5>
<?=$row['main_text'];?>
</textarea>
<?};?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question