How to get the value of a field in PHP?
        Posted  
        
            by user272899
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user272899
        
        
        
        Published on 2010-03-25T11:02:26Z
        Indexed on 
            2010/03/25
            11:13 UTC
        
        
        Read the original article
        Hit count: 332
        
I need to get the value of a field; I think I am along the right lines but not quite sure this is the proper code. The "Delete Movie" button is where I am trying to get the value of that row like so:
value="'.$row['id'].'"
Can you help?
<?php
//connect to database
mysql_connect($mysql_hostname,$mysql_user,$mysql_password);
@mysql_select_db($mysql_database) or die("<b>Unable to connect to specified database</b>");
//query databae
$query = "select * from movielist";
$result=mysql_query($query) or die('Error, insert query failed');
$row=0;
$numrows=mysql_num_rows($result);
echo "<table border=1>";
echo "<tr>
    <td>ID</td>
    <td>Type</td>
    <td>Title</td>
     <td>Description</td>
    <td>Imdb URL</td>
    <td>Year</td>
    <td>Genre</td>
    <td>Actions</td>
  </tr>";
while($row<$numrows)
{
$id=mysql_result($result,$row,"id");
$type=mysql_result($result,$row,"type");
$title=mysql_result($result,$row,"title");
$description=mysql_result($result,$row,"description");
$imdburl=mysql_result($result,$row,"imdburl");
$year=mysql_result($result,$row,"year");
$genre=mysql_result($result,$row,"genre"); ?>
  <tr>
    <td><?php echo $id; ?></td>
     <td><?php echo $type; ?></td>
    <td><?php echo $title; ?></td>
    <td><?php echo $description; ?></td>
    <td><?php echo $imdburl; ?></td>
    <td><?php echo $year; ?></td>
    <td><?php echo $genre; ?></td>
    <td>
<!-- Delete Movie Button -->
<form style="display: inline;" action="delete/" method="post" onsubmit="return movie_delete()">
<input type="hidden" name="moviedeleteid" value="'.$row['id'].'">
<button type="submit" class="tooltip table-button ui-state-default ui-corner-all" title="Delete trunk"><span class="ui-icon ui-icon-trash"></span></button>
</form> 
    </td>
    </tr>
<?php
$row++;
}
echo "</table>";
?>
© Stack Overflow or respective owner