lyrico 23 Junior Poster in Training

you can use submit instead of button. try to analyze this code.

//assume that the file name of this script is test.php
<?php

 if($_POST['submit']=="Test")
 {
    echo "test";
 }

 echo "<form action='test.php' method='post'>";
 echo "<input type='submit' name='submit' value='Test'>";
 echo "</form>";
 
?>
pritaeas commented: well spotted +14
karthik_ppts commented: Yes +7
lyrico 23 Junior Poster in Training

You can use substr.
Example.

<?php
  
  $date="March 21, 2011 - 06:30 PM";
 
  $time = substr($date,17,8); // this means you will eliminate 17 characters (March 21, 2011 - ) "including the space", and then print out the 8 characters.
  echo $time; // the output will be 06:30 PM

 
?>

you can also google substr tags.

daniel7912 commented: thanks! +0
lyrico 23 Junior Poster in Training

Just put your update query at the top, so when the page was load, the script update first the record and then display the result.

Try the code below.

<?php
$con = mysql_connect("localhost","root","");

$sql = mysql_select_db("luweegee",$con);
?>
<html>
<head><link rel='stylesheet' type='text/css' href='Style.css'/></head>
	  <body>
	  <table border=0 align='center' width=900 cellpadding=20 cellspacing=0>
	  <tr><td  class='title' colspan=2><h1>Update Record</h1></td></tr>
 
		<tr>
		<td class='borderBaba' colspan=2></td>
		</tr>
 
<tr>
<td class='form' valign='top'>
<ul>
<a class='navigation' href='View.php'><li>View Record</li></a>
<a class='navigation' href='Add.php'><li>Add Record</li></a>	
<a class='navigation' href='Edit.php'><li>Edit Record</li></a>
<a class='navigation' href='Delete.php'><li>Delete Record</li></a>
</u>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</td>
 
 
<td class='Addstyles' valign='top'>
<table class='Addstyle' border=0 width=550 cellpadding=5 cellspacing=0>
 
<?php
// put the update query here.

if($_POST['submitEditForm'])
{
	$update = mysql_query("UPDATE resume SET name='$_POST[name]', age='$_POST[age]', sex='$_POST[sex]', mobile='$_POST[mobile]' WHERE id='$_POST[idnumber]'");
		}
echo"<form method='post' action='Edit.php'>
<tr>
		<td  class='viewTable1'><center>Name</center></td>
		<td  class='viewTable1'><center>Age</center></td>
		<td  class='viewTable1'><center>Sex</center></td>
		<td  class='viewTable1'><center>Mobile</center></td>
		<td  class='viewTable1'><center>Action</center></td>
</tr>
		";
	$sel = mysql_query("SELECT * FROM resume");
	while($data=mysql_fetch_array($sel))
		{
		echo "<tr>
				<td ><center>$data[name]</center></td>
				<td><center>$data[age]</center></td>
				<td><center>$data[sex]</center></td>
				<td><center>$data[mobile]</center></td>
				<td><center><input type='submit' value='Update' name='updateButt$data[id]'></center></td>
			  </tr>";
		}
 
	echo "</table></form>";
echo "<br><BR>";
 
		for($x=0;$x<=100;$x++)
		{
			if($_POST[updateButt.$x])
			{
			$select = mysql_query("SELECT * FROM resume WHERE id=$x");
				while($data=mysql_fetch_array($select))
				{
					echo "
					<form name='myform' method='post' action='Edit.php'>
					<table border=0 cellspacing=0 align='center' class='Addstyle'>
	<tr><td align='right' class='viewTable5' colspan=2><div class='textfile'>Editing: <span class='underline'>$data[name]</span></div></td></tr>
					<input size=20 type='hidden' value=$data[id] name='idnumber'>	
					<tr><td>Name: </td><td><input type='text' size=20 name='name'/></td></tr>
					<tr><td>Age: </td><td><input type='text' size=20 name='age'/></td></tr>
					<tr><td>Sex: </td><td><input type='text' size=20 name='sex'/></td></tr>
					<tr><td>Mobile: </td><td><input type='text' size=20 name='mobile'/></td></tr>
					<tr><td colspan=2><input type='submit' value='Submit' name='submitEditForm'/></td></tr>
 
				</table></form>
				";		
				}
			}
		}
 
		
 
?>
</td>
</tr>
<tr>
<td class='borderBaba' colspan=2 align='center'>
<br>Copyright 2011 ©  All Rights Reserved<br><br>
</tr>
</td>
</table>
</body>
</html>
lyrico 23 Junior Poster in Training

I'm not sure but I think the problem is that you did not define what is $id in your update query.

//if the user press the submitEditForm, where is the $id?
if($_POST['submitEditForm'])
{
// maybe you need here something like...
$id=$_POST['id'];
$update = mysql_query("UPDATE resume SET name='".$_POST["name".$id]."', age='".$_POST["age".$id]."', sex='".$_POST["sex".$id]."', mobile='".$_POST["mobile".$id]."' WHERE id='".$id."'");
 }

In your code, the script can not identify what record you want to update. Also, I'm not sure if your update query is correct. I mean, this is the first time I saw that kind of update query. Try to declare the value of $id and try to use my suggested update query. Since your activity is urgent, I think this is the last help i can offer for today.

lyrico 23 Junior Poster in Training

oopppssss. Sorry. I forgot to include the folder ^^

$images_folder = "images/";
<td><img src="<?php echo $images_folder.$image;?>"></td>
phpDave commented: correct answer +2