PHP :Writing different forms and getting result at the same time

Hi everybody,
Here is the code for creating a website,please have a look on the attachment(It shows how my web page looks like).I have 3 forms in each row and I have almost 2000 rows.

1)my problem is whenever I choose an option from one of the forms,It shows the result for the whole coulmns (example :If I choose passed on the first row and I click submit ,It shows passed for the all the rows in this column)
So please help me if you can give me a script that it works properly.

2)Also I have another problem.my problem is each form works seprately from the other.I mean I can not see the result of 3 forms together.it does not save the result from the previous column?
[img][img][img][php][syntax=php]

<?php $db_host ="localhost"; $db_username ="***"; $db_pass ="****"; $db_name ="****";

@mysql_connect("$db_host","$db_username","$db_pass") or die (“Could not connect to mySQL”);
@mysql_select_db("$db_name") or die (“No database”);

$sql ="SELECT * FROM item_shop"; //Select everything from the Database Where the columt Id = $id
$result = mysql_query($sql);
echo “

”; //Begin of the Table
?>
<td width="6%" bgcolor="#FFA07A" ><a href="?order=orgobjid&account_id=&send=send&keytype=GUID&keyword=&seq=desc">ID</a></td>
<td width="12%" bgcolor="#FFA07A" >Name</td>

<td width="1%" bgcolor="#FFA07A" >Stacked Number:\32</td>
<td width="32%" bgcolor="#FFA07A" >Description</td>
<td width="6%" bgcolor="#FFA07A" >Type </td>
<td width="20%" bgcolor="#FFA07A" >Used Type</td>
<td width="8%" bgcolor="#FFA07A" >Verification</td>
<td width="8%" bgcolor="#FFA07A" >Item Flag</td>
<td width="40%" bgcolor="#FFA07A" >Test Comment</td>
<?php while($row = mysql_fetch_array($result)) { ?>
<td width="6%" bgcolor="#FFDEAD" ><a href="?order=orgobjid&account_id=&send=send&keytype=GUID&keyword=&seq=desc"><?php echo $row['ID']; ?></a></td>
<td width="12%" bgcolor="#FFDEAD" ><?php echo $row['Name']; ?></td>

<td width="1%" bgcolor="#FFDEAD" ><?php echo $row['Stacked_Number']; ?></td>
<td width="32%" bgcolor="#FFDEAD" ><?php echo $row['Description']; ?></td>
<td width="6%" bgcolor="#FFDEAD" ><?php echo $row['Type']; ?> </td>
<td width="20%" bgcolor="#FFDEAD" ><?php echo $row['Used_Type']; ?></td>


 <td align="center" bgcolor="#FFDEAD">
Test Result? Choose One Passed Blocked Retest Failed
Item Flag? Choose One Item Shop Phirius Tocken Shop Both
<?php echo $row['Test_Comment']; ?>
"; } echo "
     <br/>
      <textarea name="txtMessage" cols="30" rows="4"></textarea>
       <br />
       <input type="submit" name="Submit" value="Submit" />
        <input type="reset" name="Submit2" value="Reset" />
     </p>
    </form>
   </td></tr>
   </table>
   
   <? echo $_POST['txtMessage']; ?>
   
<?php echo "
"; //End of the Table ?> [/syntax][/php]

Hi,

6000 forms!? :o

Well, I think you left the processing part out of your question (and I assume that’s the part that doesn’t do what you expect)
I guess that part is doing updates on records in te database, but I noticed that you don’t pass identifiers to that script. So it has no idea what record to update.

Anyway, to answer your question we’ll need more information. ( the *****.php and ****.php file )

NOTE:
[php]
$sql ="SELECT * FROM item_shop"; //Select everything from the Database Where the columt Id = $id
[/php]
You’re not at all selecting on Id. The statement would need a ‘where’ clause like:
[php]
$sql = “SELECT * FROM ‘item_shop’ WHERE id=’$id’”;
[/php]

Also I think you should, per form, add an :
[php]

[/php]
This way your processing-script (not shown) can determine what record to update.

Good luck!
O.

PS.: You can put more inputfields that belong with the same record in the same form, that reduces the number of forms by a factor 3 and allows you to change more than one thing per record per submit.
PPS.: There are even tricks to put everything into one form.

Hi,
I want to add attachments of my website,could you please tell me how can I add attachments in here?

Ah, you had that comment in your code so I assumed you had an $id.
If you want to pull every record from that table you don’t need to change the original query.
However, you DO want the Id of the record to be able to do updates on it (like you said you wanted to)

Shall we first try to get this running before you add additional features?

So, where is the script that changes the wrong things according to you? Because this script doesn’t change anything in the database ( and you complained everything got changed ).

Laters,
O.

Hi,Thanks alot for your help,

the error comes from this line of script :
$sql =“SELECT * FROM item_shop WHERE ID =’$id’”;

Could you please tell me where I can attach file?

Sponsor our Newsletter | Privacy Policy | Terms of Service