Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Update: Retrieve record to multiline text field

Codes here !

Moderators: macek, egami, gesf

Update: Retrieve record to multiline text field

Postby wmdrumaizi » Tue May 27, 2003 7:53 pm

Hi guys;

Hi have several fields in MySQL with longtext format. I want to retrieve the record in these fields to multiline textfield to be updated.
I don't want to preview these records in single line text field because the records are quite long and not nice to be previewed in single line.
But these records won't appear in the multiline text field. They do appear when I use single line but this field type has character limit

What is MySQL field format should I use to store such record (I'm using longtext)?

p.s: I'd like to have my page act like phpforum.com-You can retrieve and edit your message.

Thanks in advance
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia

Postby Oleg Butuzov » Wed May 28, 2003 12:49 am

Code: Select all
$data=mysql_fetch_array(mysql_query("SELECT  `youfield` FROM `table`"));
echo "<textarea>$data[yourfield]</textarea>";
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby wmdrumaizi » Fri May 30, 2003 1:51 am

Thanks Pejone, it really cool but I'd like to edit the textarea i.e width and height. I use this:
<textarea style="width:50; height:20"> but I got this error

Parse error: parse error, expecting `','' or `';'' in C:\apache\htdocs\researchers\update.php on line 169

Could you help me?

Thanks in advance
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia

Postby wmdrumaizi » Fri May 30, 2003 2:00 am

Thanks Pejone, it really cool but I'd like to edit the textarea i.e width and height. I use this:
<textarea style="width:50; height:20"> but I got this error

Parse error: parse error, expecting `','' or `';'' in C:\apache\htdocs\researchers\update.php on line 169

And one more; how do I retrieve record from database to be previewed in listdown menu?

Could you help me?

Thanks in advance
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia

Postby Oleg Butuzov » Fri May 30, 2003 2:38 am

<textarea cols=70 rows=70></textarea>


you have this error becouse you use in script " and ' - sights.

do like this.
Code: Select all
echo "<font size=\"3\">test</font>";
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby liquedus » Fri May 30, 2003 5:26 am

if the script is writing the

<textarea style="width:50; height:20">

then you need to change it to

<textarea style=\"width:50; height:20\">
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

Postby Redcircle » Fri May 30, 2003 10:36 am

echo '<textarea rows="10" cols="100">the stuff</textarea>';
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby wmdrumaizi » Fri May 30, 2003 7:42 pm

Thanks a lot for your advice...

But I still haven't found the solution to retrieve the record from the database to be previewed in drop down menu.

I have a drop down menu (named org); where users can use it to insert their organisation info.
When the organisation info need to be updated I want the current record in the database be retrieved as drop down menu instead of text box.

Could someone give me any tip and advice.

Thanks in advance
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia

Postby Redcircle » Fri May 30, 2003 9:12 pm

dropdown box is completely different than a multiline text box.
Code: Select all
echo '<select name="org">';
$query = 'select id,name from org';
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
    echo '<option value='.$row['id'].'>'.$row['name'].'</option>';
}

echo '<select>';


is this what you were looking for?
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby wmdrumaizi » Sun Jun 01, 2003 10:46 pm

Hi Redcircle; thanks for your concern and reply....

I still get the drop down menu point to "-Select Organisation-"

For your information I have a table (name:org, Fields: value, label) to store the list of organisation. This is my code
Code: Select all
<?php
//Connection
$linkID = @mysql_connect("localhost", "", "") or die("Error connecting");

//Select database
mysql_select_db("researchers", $linkID);

//query- to pull all the record to be updated
$resultID = mysql_query("Select * from maintable where username = '$username'", $linkID) or die("Query Error");
$row = mysql_fetch_array($resultID);
extract($row);


//Make form
echo "<form method='post' action='update_ok.php'>";
echo "<table width=\"845\" border=\"1\" bordercolor=\"#000000\" align=\"center\" cellspacing=\"0\" cellpadding=\"1\">";

echo "<tr bordercolor=\"#000000\" bgcolor=\"#CCCCff\">";
echo "<td colspan=\"4\" bgcolor=\"#ccccff\"><b><font color=\"#000000\" size=\"2\" face=\"verdana\">::Update Form</font></b></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"15%\" bgcolor=\"#cccccc\"><font face=\"verdana\" color=\"#000000\" size=\"2\">Salutation</font></td>";
echo "<td bordercolor=\"#339999\" width=\"35%\"><font face=\"verdana\" color=\"#000000\" size=\"2\"><input name=\"salut\" type=\"text\" size=\"30\" maxlength=\"50\" value='$salut'></font></td>";
echo "<td width=\"16%\" bgcolor=\"#cccccc\"><font face=\"verdana\" color=\"#000000\" size=\"2\">Full Name</font></td>";
echo "<td bordercolor=\"#339999\" width=\"34%\"><input name=\"nama\" type=\"text\" size=\"50\" maxlength=\"50\" value='$nama'></td>";
echo "</tr>";

echo "<tr>";
echo "<td bgcolor=\"#cccccc\"><font face=\"verdana\" color=\"#000000\" size=\"2\">Instutition</font></td>";
echo "<td bordercolor=\"#339999\"><SELECT NAME='org'>";

// Run query to get data for drop-down menu
$query = 'select value, label from org';
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo '<option value='.$row['value'].'>'.$row['label'].'</option>';
}
echo "</select>";


And one more thing, if the record in the database is not listed in the drop-down menu; how do I set the org to "Other" and textbox (org2) display that unlisted value....

Thanks in advance
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia

Postby Redcircle » Mon Jun 02, 2003 12:12 am

You would have to post the form to itself by changing the action to "" and then make the form post using onChange when the org combobox changes.

<form action="" method="post">


echo '<select onChange="Submit();" name="org">';

then you add

echo '<option value="other"';
if($_POST['org'] == "other")
{
echo ' selected';
}
echo '>Other</option>';

after the
echo "</select>";

add

if($_POST['org'] == "other")
{
echo '<input type="text" name="org2">';
}
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby wmdrumaizi » Mon Jun 02, 2003 8:55 pm

Guys, thanks a lot for your help.
I'm feeling lucky to have a very concern friends.

Thanks and regards
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron