Echo-Feld-Wert In Textfeld

Ich Frage mich, ob jemand möglicherweise in der Lage, mir zu helfen, bitte.

Durch einige Anleitung erhielt ich früher von dieser Seite habe ich die Möglichkeit, zusammen zu stellen, Skript, unten aufgeführt, aktuelle Informationen werden mit einem zugehörigen radio button ermöglicht jeden Datensatz ausgewählt werden.

<?php

mysql_connect("hostname", "username", "password")or
die(mysql_error());
mysql_select_db("database");
?>
<html><head> 
<title>Location</title>
<style type="text/css">
<!--
.style3 {
    font-size: 18px;
    font-family: Calibri;
}
-->
</style>
</head>
<form name="addimages">
  <p>
    <label>
    <div align="center" class="style3"> Location Name <br>
      <br>
      <input name="locationname" type="text" value="<?php echo $locationname;?>" id="locationname" size="80">
    </div>
    </label>
  </p> 
  <p>&nbsp;</p>
  <p>
    <?php

$result = mysql_query("SELECT userdetails.userid, finds.dateoftrip, finds.userid, finds.locationid, detectinglocations.locationid, detectinglocations.locationname,  finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1 ORDER BY dateoftrip DESC");
if (mysql_num_rows($result) == 0)
//table is empty
  echo 'There are currently no finds recorded for this location.';
 else
{

  while (list($userid, $dateoftrip, $locationname) =
    mysql_fetch_row($result))

  {  
      echo"<table>\n"; 
      echo"<tr>\n"
    .
     "<td><input type='radio' name='radio' dateoftrip value='{$userid}' /></td>\n"
    ."<td><small>{$dateoftrip}</small><td>\n"
    ."</tr>\n";
  }
  echo"<tr><td colspan=\"3\">";
  echo"<br>";
  echo"</td></tr>";
  echo'</table>';
}
?>
</p>
</form>

Was ich jetzt versucht bin zu tun ist, fügen Sie die 'locationname' - Wert zu dem entsprechenden Textfeld.

Habe ich value="<?php echo $locationname;?>" auf das textfield, aber es bleibt leer.

Ich denke, das problem liegt hier:

while (list($userid, $dateoftrip, $locationname) = mysql_fetch_row($result)) die ich verwenden, um die Informationen für die Liste der Termine, während normalerweise würde ich dieses verwenden:

while ($row = mysql_fetch_array($result))
{
$locationname = $row['locationname'];
zu Holen, der Wert für ein Textfeld.

Könnte mir jemand vielleicht sagen Sie mir bitte gibt es eine Möglichkeit, dass ich kombiniere die beiden Aussagen zusammen zu bringen zwei Stücke von Informationen, die ich brauche, d.h. die Tabelle enthält die Liste der Termine während 'echo' die 'locationname' Wert in das Textfeld ein.

Vielen Dank

AKTUALISIERTEN CODE

<?php
mysql_connect("hostname", "username", "password")or
die(mysql_error());
mysql_select_db("database");

$locationname=''; 
$result = mysql_query("SELECT userdetails.userid, finds.dateoftrip, finds.userid, finds.locationid, detectinglocations.locationid, detectinglocations.locationname,  finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1 ORDER BY dateoftrip DESC");
if (mysql_num_rows($result) == 0){
//table is empty
  $return = 'There are currently no finds recorded for this location.'; 
  }else{     
  $return="<table>\n";     
  while (list($userid, $dateoftrip, $locationname) = mysql_fetch_row($result)){ 

$return .="<tr>\n". 
"<td><input type='radio' name='radio' dateoftrip value='{$userid}' /></td>\n" 
."<td><small>{$dateoftrip}</small><td>\n" 
."</tr>\n"; 
} 
$return .="<tr><td colspan=\"3\"><br>"; 
} 
?>
<form name="addfinds">

      <input name="locationname" type="text" value="<?php echo $locationname;?>" id="locationname" size="80">   
  <p>&nbsp;</p> 
  <p> 
    <?php echo $return;?> 
</p> 
</form> 
InformationsquelleAutor IRHM | 2012-02-22
Schreibe einen Kommentar