Take a Loook.....I am just stucked
Posted: Tue Jan 06, 2004 10:43 pm
This is a form which lets users modify the value of DB table. There is one text box that takes the primary key value which is call_no, and a button called modify.
When the user suppies a call_no and hits the modify button mtest.php gets called.
mtest.php looks like:
Call No and Book Title are two columns in my book table. So when user wants to modify call no= 1 and hits modify button mtest.php file retrives the specific row from the book table and displays it in two text field - call no and title.
User then changes the value and press save new value button. The value gets saved.
I have a number of questions:
1) I know how to display data in a table format but if do so it does not let me to change any value. It is read only. If i use text box instead to display my retrieved data will they let me to change value online?
2) what mistakes i made in the following code that does not display retrieved data in those two text fields?
Where it works fine here in case of a table?
Code: Select all
<html>
<body>
<form method="post" action="mtest.php">
<table border="0" width="75%">
<tr>
<td width="15%">
<p align="right">Call No:</p>
</td>
<td width="57%"><input type="text" name="call_no" size="20"></td>
</tr>
<input type="submit" value="Modify " name="Modify">
</table>
</form>
</body>
</html>mtest.php looks like:
Code: Select all
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("library",$db) or die(mysql_error());
$sql = "Select * FROM book WHERE author1=('{$_POSTї'call_no']}')";
$result = mysql_query($sql);
?>
<table border="0" width="75%">
<tr>
<td width="15%">Call No</td>
<td width="62%"><input type="text" name="call_no" size="20"></td>
</tr>
<tr>
<td width="15%">Book Title</td>
<td width="62%"><input type="text" name="title" size="20"></td>
</tr>
<tr>
<td width="100%" colspan="3"></td>
</tr>
<td height="38"><input type="submit" value="save new values" name="savenewvalues">
<td height="61">
<?php
while ($myrow = mysql_fetch_row($result))
{
echo '<tr>';
for($i=0; $i<10; $i++)
{
echo '<td>'.$myrowї$i].'</td>';
}
echo '</tr>';
}
?>
</table>
</body>
</html>Call No and Book Title are two columns in my book table. So when user wants to modify call no= 1 and hits modify button mtest.php file retrives the specific row from the book table and displays it in two text field - call no and title.
User then changes the value and press save new value button. The value gets saved.
I have a number of questions:
1) I know how to display data in a table format but if do so it does not let me to change any value. It is read only. If i use text box instead to display my retrieved data will they let me to change value online?
2) what mistakes i made in the following code that does not display retrieved data in those two text fields?
Code: Select all
while ($myrow = mysql_fetch_row($result))
{
echo '<tr>';
for($i=0; $i<10; $i++)
{
echo '<td>'.$myrowї$i].'</td>';
}
echo '</tr>';
}Where it works fine here in case of a table?
Code: Select all
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("library",$db) or die(mysql_error());
$result = mysql_query("SELECT * FROM book",$db);
?>
<table border=2>
<tr>
<td>call_no</td>
<td>title</td>
</tr>
<?php
while ($myrow = mysql_fetch_row($result))
{
echo '<tr>';
for($i=0; $i<10; $i++)
{
echo '<td>'.$myrowї$i].'</td>';
}
echo '</tr>';
}
?>
</table>