Jump to content

How to Handle this form?


mike12255

Recommended Posts

So i got a table that looks somthing like this:

 

File Name | Download | Suggested Catagory | Select Catagory | Approve

--------------------------------------------------------------------------------------

test          | Download | blah    blah blah      | Option menu    | yes or no option menu

test          | Download | blah    blah blah      | Option menu    | yes or no option menu

test          | Download | blah    blah blah      | Option menu    | yes or no option menu

 

 

what I want to do is in the file that processes this it only looks at the ones that have had the "approve column" submitted as a yes. Next it will to a mysql entry into verrified notes. Problem is with X amount of entries in that form I dont know how to look at only the ones that have said yes. Do I create a new form for each entry or put them all as one entry and after this what do I do next?

Link to comment
Share on other sites

Its wrote through php echos but ill give you the view source html

 

I have not added any forms or sumbit button yet so it is just a table because im not quite sure how to go about making a form with somthing like this:

<table align="left" border="1" cellspacing="0" cellpadding="3"> 
   <tr><td><b>Author</b></td><td><b>File name</b></td><td><b>Download</b></td><td><b>Suggested catagory</b></td><td><b>Select Catagory</b></td><td>Approve</td></tr> 
   <td>MikeH</td> <td> A lot of my skills set back </td><td><a href= /uzEr%20Upl0ds/cache.zip > Download</a></td><td> 1001 Laws - Polceing </td><td><select name="scatagory"><option value="1"> Intro To Law </option><option value="2"> 1001 Laws - Police Foundations </option></select></td><td><select name = "approve"> 

<option value = "1"> Yes</option> 
<option value = "2"> no</option> 
</select></td></tr><td>MikeH</td> <td> MM </td><td><a href= /uzEr%20Upl0ds/Michael Heintzman.doc > Download</a></td><td> 1001 Laws - Polceing </td><td><select name="scatagory"><option value="1"> Intro To Law </option><option value="2"> 1001 Laws - Police Foundations </option></select></td><td><select name = "approve"> 

<option value = "1"> Yes</option> 
<option value = "2"> no</option> 
</select></td></tr>    
    
    </table> 
    

 

Link to comment
Share on other sites

Each row = a new form but you would have to send each form one at a time

 

or

 

step1: one form starting at the top of the table and finishing at the bottom.

step2: Created by a loop: Each cell in the table has a hidden field with the value of the cell in it

    eg:  row1 of hidden fields could be: 

<input type="hidden" name="r1_author" value="mke"/><input type="hidden" name="r1_file" value="filename"/>...etc

    eg:  row2 of hidden fields could be: 

<input type="hidden" name="r2_author" value="mke"/><input type="hidden" name="r2_file" value="filename"/>...etc

 

step3: processed by a loop (you may want a table row count field somewhere). Obviously when the processing loop hits approved no, do nothing

Link to comment
Share on other sites

Ok, how is this? Also the fields will not always be the same they change depending on what info is in the database.

 

 

<table align="left" border="1" cellspacing="0" cellpadding="3">
  <tr>
    <td><b>Author</b></td>
    <td><b>File name</b></td>
    <td><b>Download</b></td>
    <td><b>Suggested catagory</b></td>
    <td><b>Select Catagory</b></td>
    <td>Approve</td>
  </tr>
  <td>MikeH</td>
    <td> A lot of my skills set back </td>
    <td><a href= /uzEr%20Upl0ds/cache.zip > Download</a></td>
    <td> 1001 Laws - Polceing </td>
    <td><select name="scatagory">
        <option value="1"> Intro To Law </option>
        <option value="2"> 1001 Laws - Police Foundations </option>
      </select></td>
    <td><select name = "approve">
        <option value = "1"> Yes</option>
        <option value = "2"> no</option>
      </select></td>
  </tr><td>MikeH</td>
    <td> MM </td>
    <td><a href= /uzEr%20Upl0ds/Michael Heintzman.doc > Download</a></td>
    <td> 1001 Laws - Polceing </td>
    <td><select name="scatagory">
        <option value="1"> Intro To Law </option>
        <option value="2"> 1001 Laws - Police Foundations </option>
      </select></td>
    <td><select name = "approve">
        <option value = "1"> Yes</option>
        <option value = "2"> no</option>
      </select></td>
  </tr>
</table>

 

Link to comment
Share on other sites

The html form you created (i've only included a few table columns, i have changed the content of each cell to a "disabled" "text" input). Obviously the name of each input will be different depending on the row it is in, eg: tr1_author  tr2_author  tr3_author  ...etc

<form action="thisphpscript.php" method="post">
<table align="left" border="1" cellspacing="0" cellpadding="3">
<tr>
    <td><b>Author</b></td>
    <td><b>File name</b></td>
    <td>Approve</td>
</tr>
<tr>
    <td>
	<input type="text" disabled="disabled" name="tr1_author" value="MikeH"/>
</td>
    <td>
    	<input type="text" disabled="disabled" name="tr1_fileName" value="A lot of my skills set back"/>
    </td>
    <td>
    	<select name = "tr1_approve">
        <option value = "1"> Yes</option>
        <option value = "2"> no</option>
	</select>
</td>
</tr>
</table>
<input type="hidden" name="rowCount" value="1">
<input type="submit" name="sendData" value="send"/>
</form>

 

 

the php to process the data:

 

if(isset($_POST['send']))
{
	$dataArray = array();

	$row_count = $_POST['rowCount'];
	for($i=0;$i<$row_count;++$i)
		{
			$approve = "tr".$i."_approve";
			if($approve == 1)
				{
					//setting the post names to catch:
					$author = "tr".$i."_author";
					$fileNmae = "tr".$i."_fileName";
					$dataArray[]=array('author'=>$author,'fileName'=>$fileName);
				}
		}

	if(!empty($dataArray))
		{
			//now do what you want with the dataArray...				
		}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.