Question : Sql query and php issue.

I have this code which simply retrieves rows for one table. Next to each row has a submit button.

this code appears to be correct.

But when I process the page, after clicking the submit button next to row, I always end up with the same result.

The result is the last row of the result on form page.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
<form action='send_email.php' method='post'>         
<table border='1' cellspacing='0' cellpadding='6'>
<?php
$query = "SELECT * FROM projects";
$result = mysql_query($query) or die ("Couldn't execute query.");
$numofrows = mysql_num_rows($result);
for($i = 0; $i < $numofrows; $i++) {
    $row = mysql_fetch_array($result);
	
echo"<tr>";

			
		
		echo"<td>
		<input name='projectid' type='text' value='".$row['projectid']."' size='22'>
		<input name='project' type='text' value='".$row['project']."' size='22'>
		<input type='submit' name='button' id='button' value='Submit' /></td>
		";
		}
		echo"</tr>";	
?>
</table> 
</form> 



-----

send_email.php


Projectid: <?php echo $_POST["projectid"]; ?><br />
Project: <?php echo $_POST["project"]; ?>

results are always now matter which button on click on to next to the row. 


Projectid: 7
Project: szdsadfg

Answer : Sql query and php issue.

once you pass those parameters as variables to SQL then you can do something like this:

1:
2:
3:
4:
5:
select ... from yourtable
where 	(@year is null or [year] = @year) and
	(@Model is null or Model = @model) and
	(@make is null or make = @make) and
	.... and so on ....
Random Solutions  
 
programming4us programming4us