Page 1 of 1

PHP recordset Array

Posted: Mon Jun 13, 2005 5:49 am
by AXEmonster
Hi Guys
Can anyone help with this
I am passing (submiting) the following values to a report page from a textfield called ..(sqlvar)

Code: Select all

input name=&quote;sqlvar&quote; type=&quote;hidden&quote; value= ... 

$row_recordsetї'field1']¦$row_recordsetї'field2']¦$row_recordsetї'field3']¦$row_recordsetї'field4']
...........
these are in one hidden field as you see above and the length can change dynamically

i am using the following on the receiving page

Code: Select all

$sqlvariable = $_POSTї'sqlvar']; 

$sqlvariable =stripslashes($sqlvariable); 

if ($sqlvariable!=''){ 

$strarray2 = explode('¦',$sqlvariable ); 
$carray = count($strarray2 ); 

for ($i=0; $i < $carray; $i++){ 

$td2 = $td2.'<td><?php echo'.$strarray2&#1111;$i].'?></td>'; 

}

Code: Select all

<body >
 <table>

<? this will be a DO loop { ?>
    <tr>
     
      <?php echo $td2; ?>
 
    </tr>
 <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

 </table>

how can i proccess $strarray2[$i] as the var $row_recordset['fields']from the database

Posted: Mon Jun 13, 2005 5:55 am
by phpScott
why are you doing a count on $sqlvariable instead of $strarray2

count() returns how many elements are in an array;

to answer your question we probably need to know what your table looks like.

Posted: Mon Jun 13, 2005 6:03 am
by AXEmonster
phpScott wrote:why are you doing a count on $sqlvariable instead of $strarray2.
sorry Scott my mistake when composing this help request.
I am doing a count on $strarray

The table is like this

Code: Select all

<table> 
 <tr>           
    <?php echo $td1; ?>     
  </tr> 
<? this will be a DO loop { ?>    
  <tr>           
    <?php echo $td2; ?>     
  </tr> 
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>  
</table>

/// this is how it looks after processing

Code: Select all

<table width=&quote;282&quote; cellspacing=&quote;0&quote; cellpadding=&quote;0&quote; border=&quote;1&quote;>
  <tr class=&quote;table-header&quote;>
    <td>*inv_id </td>
    <td> inv_keyer </td>
    <td> inv_no </td>
    <td> inv_type </td>
    <td> inv_status</td>  
 </tr>
  <tr>
    <td><?php echo $row_Recordset1&#1111;'inv_id']; ?></td>
    <td><?php echo $row_Recordset1&#1111;'inv_keyer']; ?></td>
    <td><?php echo $row_Recordset1&#1111;'inv_no']; ?></td>
    <td><?php echo $row_Recordset1&#1111;'inv_type']; ?></td>
    <td><?php echo $row_Recordset1&#1111;'inv_status']; ?></td>  
 </tr>
</table>
////////////////////////

$td1 generates the column heders in the same way and is working ok.
The best i got was the the table formatting correctly but with $row_recordset1['fields'] being output as a literal string under each heading