I need to get values from a postgre db and use the fopen to open the link inside its records to open real xml file.
<?php
echo "<form id=read2 method=post action=read2.php>";
//other html and table codes
while ($row = pg_fetch_row($result)) {
echo "<tr><td>$row[1]</td><td><input type=hidden name=data value=$row[3] /><a href=javascript:; onclick=document.getElementById('read2').submit();>$row[2]</a></td><td>$row[4]</td><td>$row[5]</td></tr>";
}
the read2.php:
<?php
$data=$_POST['data'];
$explode = explode("/inbox/", $data);
$final = "";
$final.="data/";
$final.=$explode[1];
echo "Result of data before explode is: $data <br />";
echo "Result of data after explode is: $explode[1] <br /><br />";
$myfile = fopen("$final", "r") or die("<h1>Unable to open file!</h1>");
$xml = htmlspecialchars(fread($myfile,filesize("$final")));
?>
<pre>
<?php echo $xml; ?>
</pre>
<?php fclose($myfile); ?>
My problem is here: <input type=hidden name=data value=$row[3] />
I am able to pass to read2.php the correct value and use the explode to adjust what I really need, but I am not able to chose which value to get due to name=data which is the same for all and the read2.php only get the last one in list.
I tried with a counter inside the while: name=data[count]; count++
But in this case I do not know how to get "name" from $_POST
It is also possible that the javascript code I use to send the form is not the best for this situation. Can you please help me fix?
<form id="read2" method="post" ....."characters in, at least, until they cause some terrible bug or failure in a specific browser, once your code is live.