Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving certain types of information from MySQL Database 2

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
I currently have a form that retrieves information from a mysql database.
This form can also be used to update information.
I can get the text box information out no problem.
But I can not retrieve the following and I do not want to convert them to a text box.
I have tried putting value=$whatever into them but none worked

1) How do I return the value from the database into the following
This holds the location of a file.
<input type=&quot;file&quot; size=&quot;60&quot; name=&quot;find_file&quot;>
I need to maintain this input type as the file location may change.

2) How do I return the value from the database into the following
<textarea name=&quot;comments&quot; rows=&quot;8&quot; cols=&quot;40&quot;></textarea>

3)How do I return the value from the database into the following dropdown list.
Again this value may need to be changed.
<?php
$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;) or die ('Cannot connect to database');
mysql_select_db(&quot;data&quot;,$db) or die ('database not available');
$sql='SELECT * FROM Names';
$result = mysql_query($sql,$db);
echo &quot;<select name=first>\n&quot;;
while ($row = mysql_fetch_array($result)) {
echo &quot;<option value=$row[0]>$row[0]</option>\n&quot;;
}
echo &quot;</select>\n&quot;;
?>

Thanking you for any help received

 
These are HTML questions and should have been asked in that forum. But I'll answer anyway.

1. You would use that tag's &quot;value&quot; attribute. For more information:
2. Put the data between the tags. For more information:
3. If with this one you mean to ask, &quot;How do I initialize the value of a 'select' tag?&quot; You would insert the attributed &quot;selected&quot; as a part of the option you wish to be the default value. For more information: ______________________________________________________________________
TANSTAAFL!
 
query

$query=&quot;SELECT * FROM yourtablename where tablekey='$id'&quot;;
$rs=mysql_query($query,$conn);
$aantal=mysql_num_rows($rs);
$row=mysql_fetch_array($rs);
$msn=$row[&quot;llumsn&quot;];
$lluintro=$row[&quot;lluintro&quot;];


1.<INPUT TYPE=\&quot;text\&quot; name=\&quot;llumsn\&quot; size=50 value=$msn>

2.<TEXTAREA NAME=\&quot;lluintro\&quot; ROWS=10 COLS=45 WRAP=\&quot;VIRTUAL\&quot;>$lluintro</TEXTAREA></td></tr>

3.
query
$query=&quot;SELECT distinct(whname) FROM whiskytable order by whname&quot;;
$rs=mysql_query($query,$conn);

<tr><td><p>Whisky</P></TD><td><select name=&quot;whname&quot;><option value=&quot;&quot;>Empty
<?
$list = mysql_num_rows($rs);
while($i < $list) {
$row = mysql_fetch_array($rs);
$whname=$row[&quot;whname&quot;];
echo &quot;<option value='$whname'>$whname&quot;;
$i++;
}
?>
</select></TD><td></td></TR>

greetings
hos
 
Thanks very much for your help.
I have got 2 of them sorted.
According to the value tag should work but it doesn't.

Does anything look obviously wrong with the following.
<input type=&quot;file&quot; size=&quot;60&quot; name=&quot;find_file&quot; value=&quot;<?php echo $myrow4[Entered_By] ?>&quot;>
 
Hi Lads

Forget about it.
I checked the HTML forum and it seems it can not be done easily without altering some PC settings.

Again thanks for your help on everything else.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top