Jump to content

Putting database results into form fields


trassalg

Recommended Posts

I've placed the two documents below so you can see.  I've tried both not putting any value into the form fields as well as value="$row['articleText']", for example.

 

what are you putting in for the values in your form fields?

 

walkThru.php

<html>
<head>
<title>Baso de datos de Rodolfo</title>
<link href="styles/cal.css" rel="stylesheet" type="text/css">
<script type="text/javascript"> 
function confirmDelete() { 
return confirm("¿Estas seguro que lo queres borrar?");   
} 
calendarLanguage = "spanish";
calendarDateFormat = "%yyyy%-%mm%-%dd%";
</script>
<script src="includes/cal.js"></script>
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>
<?php
include("includes/misc.inc");
include("includes/connection.inc");
include("includes/menuBar.php");


	    $result = mysql_query("SELECT * FROM articleTable ORDER BY articleIDNumber");
	    while ($row = mysql_fetch_array($result)) {
				}

	    $ud_id = $_POST['articleIDNumber'];
	    $ud_title = $_POST['articleTitle'];
	    $ud_text = $_POST['articleText'];
	    $ud_author = $_POST['author'];
	    $ud_source = $_POST['source'];

?>
</head>
<body>
<table align="center" border="1" width="850">
<tr>
  	<td colspan="4" align="center"><h1>Editar/Actualizar Articulos</h1></td>
  </tr>
<form method="post" action="walkThru_edit.php">
  <tr>
  	<td colspan="3"></td>
	<td rowspan="8" colspan="2" height="400" width="100">Categorías:<br><br><div style="height: 400px; width: 300; overflow: auto"><?php include("categories_add.php"); ?></div></td>
  </tr>
<tr>
	<td># de identificación</td>
	<td><input type="text" name="articleIDNumber" value="<?php echo "$articleIDNumber"; ?>"></td>
</tr>
<tr>
	<td>Fecha del artículo</td>
	<td><input type="text" name="dateOfArticle" id="dateOfArticle">
    <img src="images/calendar.gif" onClick="loadCal(this)" id="cal-dateOfArticle"><br>
    </td>
</tr>
<tr>
	<td>Autor</td>
	<td><input type="text" name="author" value="<?php echo "$author"; ?>"></td>
</tr>
<tr>
	<td>Fuente</td>
	<td><input type="text" name="source" value="<?php echo "$source"; ?>"></td>
</tr>
<tr>
	<td>Titulo</td>
	<td><input type="text" name="articleTitle" value="<?php echo "$articleTitle"; ?>"></td>
</tr>
<tr>
	<td>Texto</td>
	<td><textarea cols="50" rows="20" input type="text" name="articleText" value="<?php echo "$articleText"; ?>"></textarea></td>
</tr>
  <tr>
    <td align="left" colspan="2">
		<table>
      	<tr>
        	<td align="left"><input type="Submit" value="Ingresar"></td>
    			<td width="80%"></td>
  			</tr>
      </table>
    </td>
  </tr>
</form>
</table>
</body>
</html>

 

walkthru_edit.php

<html>
<head>
<title>Baso de datos de Rodolfo</title>
<link href="styles/cal.css" rel="stylesheet" type="text/css">
<script type="text/javascript"> 
function confirmDelete() { 
return confirm("¿Estas seguro que lo queres borrar?");   
} 
</script>
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>
</head>
<body>


<?php
include("includes/misc.inc");
include("includes/connection.inc");
include("includes/menuBar.php");

$post_article_id = $_POST['$articleIDNumber'];

	    $result = mysql_query("SELECT * FROM articleTable WHERE articleIDNumber=$post_article_id ORDER BY articleIDNumber");
	    while ($row = mysql_fetch_array($result)) {

	    $ud_id = $_POST['articleIDNumber'];
	    $ud_title = $_POST['articleTitle'];
	    $ud_text = $_POST['articleText'];
	    $ud_author = $_POST['author'];
			$ud_author2 = $_POST['author2'];
	    $ud_source = $_POST['source'];
			$ud_source2 = $_POST['source2'];

// The problem is somewhere here within the WHILE loop above... try playing with the opening and closing {}'s to see where a good spot for them to go is(?), because the loop on the bottom of this page is working fine, therefore the same values should work the same on the top.  Also what in the bottom part of the page is making it a GET command, feeding the data into the url rather than as a post command, feeding it into their respective form fields?


?>

<table align="center" border="1" width="850">
<form method="post" action="walkThru_update.php">
<tr>
  	<td colspan="4" align="center"><font size="+3">Editar/Actualizar Articulos</font></td>
  </tr>
  <tr>
  	<td colspan="3"></td>
	<td rowspan="8" colspan="2" height="400" width="100" valign="top">Categorías:<br><br><div style="height: 400px; width: 300; overflow: auto"><?php include("categories_edit.php"); ?></div></td>
  </tr>
<tr>
	<td># de identificación</td>
	<td><input type="text" name="articleIDNumber" value="<?php echo "$articleIDNumber"; ?>"></td>
</tr>
<tr>
	<td>Fecha del artículo</td>
	<td><input type="text" name="dateOfArticle" value="<?php echo "$dateOfArticle"; ?>"></td>
</tr>
<tr>
	<td>Autor</td>
		<td><input type="text" name="author2" value="<?php echo "$author"; ?>"><font color="#FF0000"><strong>   O   </strong></font><?php include("dropdown_author_add.php"); ?></td>
</tr>
<tr>
	<td>Fuente</td>
		<td><input type="text" name="source2" value="<?php echo "$source"; ?>"><font color="#FF0000"><strong>   O   </strong></font><?php include("dropdown_source_add.php"); ?></td>
</tr>
<tr>
	<td>Titulo</td>
	<td><input type="text" name="articleTitle" value="<?php echo "$articleTitle"; ?>"></td>
</tr>
<tr>
	<td>Texto</td>
	<td><textarea cols="50" rows="20" input type="text" name="articleText"><?php echo $row['articleText']; ?></textarea></td>
</tr>

    <td align="center">
		<table>
      	<tr>
				<td width="20%"></td>
				<td width="20%"></td>
				<?php 
        		include("includes/misc.inc");
        		include("includes/connection.inc");
      
             $result = mysql_query("SELECT * FROM articleTable WHERE articleIDNumber=$articleIDNumber ORDER BY articleIDNumber");
              while ($row = mysql_fetch_array($result)) {
            ?></td>
        	<td width="20%" align="center"><input type="Submit" value="Submit"></td>
				<td width="20%"></td>
				<td width="20%"></td>
  			</tr>
        <tr>
				<td colspan="5" align="center" valign="bottom"><br><font size="+2" color="#FF0000">Articulo #<? echo $row['articleIDNumber']; ?>...</font></td>
        </tr>
        <tr>
          <td width="20%"></td>
          <td width="20%" align="center"><a href="walkThru_edit.php?articleIDNumber=<? echo $row['articleIDNumber']; ?>&dateOfArticle=<? echo $row['dateOfArticle']; ?>&articleTitle=<? echo $row['articleTitle']; ?>&articleText=<? echo $row['articleText']; ?>&author=<? echo $row['author']; ?>&source=<? echo $row['source']; ?>"><font size="+3">Editar</font></a></td>
          <td width="20%"></td>
          <td width="20%" align="center"><a href="walkThru_delete.php?articleIDNumber=<? echo $row['articleIDNumber']; ?>" onClick="return confirmDelete()"><font size="+3">Borrar</font></a></td>
          <td width="20%"></td>
        </tr>
      </table>
    </td>
  </tr>
		<?
	    } // Closes While Loop
	?>


</form>
</table>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.