Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

_SESSION variables in a loop in a form 2

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
GR
Consider this (after a query):
Code:
    while($row = mysqli_fetch_array($result,MYSQLI_NUM)):
$html='<html>
<body>
<table width="100%" border="1">
  <tr>
    <th>$row[1]</th>
    <th>$row[2]</th>
    <th>$row[4]</th>
    <th>$row[5]</th>
    <th>$row[6]</th>
    <th>HREF="dosomething.php" Do something with row[6]</th> ';
echo $html;
endwhile;

Basically this produces a table and for each table entry, the user may click and select to do something for that entry ($row). So somehow I need to pass the $row to the dosomething form.
One way we discussed is
Code:
$_SESSION["row"]=$row
, but this assumes that at the time the user clicks the $_SESSION[row] is the current row, rather than the last row produced by the query.
A similar way might be
Code:
 <th>HREF="dosomething.php?variable=$row[6]" Do something with row[6]</th> ';

I am not sure this will work, since the table appears first, before the user decides to click.
So I am curious how would one do that, i.e. "package" the row with the form called.
 
svar said:
1) Unless I misunderstood something, script=the set of the initial file/link (e.g initial.php) plus all php files and children thereof called by the initial file accessed by the browser.

More like requested. The Browser requests file1.php. Whatever file1.php includes or requires i.e (include("path/to/file3.php");) while running and uses is still the same script execution.

svar said:
Door 1, which is a php file does a query, displays some dynamically generated html and offers you a choice of hyperlinks. You click on one of them and get php file Door2. Door 1 has closed, but $_SESSION vaiables generated by Door1 is not erased and the script (in the sense I understand it) has not finished running. Or does script refer to each php file?quote+

When the page is displayed in the browser that PHP script has stopped executing there is only static HTML left. The Browser will onyl ever get HTML (NO PHP is delivered to the browser) which is delivered by the server once the PHP script finishes what its doing. When you see the page, with the hyperlinks, PHP has stopped running and your script execution is over. When you click on a hyperlink you initiate a new script execution by requesting a new file. This new script takes the SESSION ID that was given to the browser by your first script (i.e file1.php and all its included files) and looks for the correct SESSION to open in the SESSION directory.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top