Jump to content

Array probems...


messer

Recommended Posts

I have an dynamic row,that can be duplicated as many times as i want :

                        
  ....
                                  <tr >
			        <td class="txt_rapport" ><input  name="pos[]" type="text"   size=5 /></td>
				<td class="txt_rapport" >' ;?> <? echo menu_select();?>  <? echo'</td>
				<td class="txt_rapport" >' ;?> <? echo bon_select();?>  <? echo'</td>
				<td class="txt_rapport" ><input  name="nrl[]" type="text"   size=5 /></td>

			  </tr> ';
<p><div align="left">
<a href="javascript://" onClick="new_row()"><input type="button" value="Add Article"></a><div> <div align="right"><a href="javascript://" onClick="delete_row()"><input type="button" value="Delete Article"></a><div></p>
                                                ...
                                       <div align="center"><input name="submit" type="submit" value=" Next " /><div>
                          </form> ';
break;
case'rapport':

if(!isset($_POST['pos'])) $_SESSION['pos'] = '';
else $_SESSION['pos'] = $_POST['pos'];


if(!isset($_POST['bon'])) $_SESSION['bon'] = '';
else $_SESSION['bon'] = $_POST['bon'];

if(!isset($_POST['aticles'])) $_SESSION['aticles'] = '';
else $_SESSION['aticles'] = $_POST['aticles'];

if(!isset($_POST['nr'])) $_SESSION['nr'] = '';
else $_SESSION['nr'] = $_POST['nr'];
                                                          ....

 

And here is my problem, I don't know how to arrange those arrays in such a way that each value to be correct arranged...

 

I've tried something like this but it doesn't arrange correctly :

 

        .....
rsort($_SESSION['pos'],SORT_STRING);
rsort($_SESSION['bon']);
rsort($_SESSION['nr']);

$check=0;

foreach($_SESSION['bon'] as $key=>$value) 
{
$query_art="SELECT * FROM articles WHERE ArtID='".$_SESSION['articles'][$key]."'";
$result_art=mysql_query($query_art);
$Row_art = mysql_fetch_array ($result_art);

if ($check != $_SESSION['bon'][$key]) {

$query_bon="SELECT * FROM bon WHERE ID='".$_SESSION['bon'][$key]."'";
$result_bon=mysql_query($query_bon);
$Row_bon = mysql_fetch_array ($result_bon);

		echo' <tr >
				<td class="txt_rapport" colspan=4><b>bon:</b>'.$Row_bon['BonNumer'].' ( '.$Row_bon['BonDatum'].')</td>				
			</tr>
			<tr>
				<td class="txt_rapport" align="right">'.$_SESSION['pos'][$key].'</td>
				<td class="txt_rapport" align="left">   '.$Row_art['Teilnumer'].'</td>
				<td class="txt_rapport" align="left">   '.$Row_art['Art_Description'].'</td>
				<td class="txt_rapport">'.$_SESSION['nr'][$key].'</td>';
	         echo' </tr>';
}else {

echo' 			<tr>
                <td class="txt_rapport" align="right">'.$_SESSION['pos'][$key].'</td>
				<td class="txt_rapport" align="left">   '.$Row_art['Teilnummer'].'</td>
				<td class="txt_rapport" align="left">   '.$Row_art['Art_Description'].'</td>
				<td class="txt_rapport">'.$_SESSION['nr'][$key].'</td>';
		 echo' </tr>';
}
$check=$_SESSION['bon'][$key];

}
      ......

 

Please some one to help me pls...

 

 

 

Link to comment
Share on other sites

No, it's the other way around. I don't understand you. Could you explain what you mean by arrange correctly?

 

If I have numbers 1,2,3,4,5 and I ask you to arrange them correctly, that wouldn't make sense unless I tell you how I want them to be arranged. Now, it's your turn. Please explain arrange correctly.

Link to comment
Share on other sites

Here is my dynamic row:

....
<tr>
<td>$valueX[]</td> <td>$valueY[]</td> <td>$valueZ[]</td> <td>$valueW[]</td>
</tr>
<tr>
<td>$valueX[]</td> <td>$valueY[]</td> <td>$valueZ[]</td> <td>$valueW[]</td>
</tr>
<tr>
<td>$valueX[]</td> <td>$valueY[]</td> <td>$valueZ[]</td> <td>$valueW[]</td>
</tr>
....

And after i press NEXT these arrays are goind to under case'rapport':

Link to comment
Share on other sites

....
<tr>
<td>$valueX[]</td> <td>$valueY[]</td> <td>$valueZ[]</td> <td>$valueW[]</td>
</tr>
<tr>
<td>$valueX[]</td> <td>$valueY[]</td> <td>$valueZ[]</td> <td>$valueW[]</td>
</tr>
<tr>
<td>$valueX[]</td> <td>$valueY[]</td> <td>$valueZ[]</td> <td>$valueW[]</td>
</tr>
....

 

And I want to arrange in such way : for example all values from the 3rd row then values from then 1st row the value from then 2nd row, and each time it can be different, so , to arrange them also dynamicaly, but values to corespond from their original row...

Now i hope that you understand me....

 

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.