Forum Moderators: coopster
while ($row==mysql_fetch_array($myquery,$myconn)) {
...
}
within this loop I have hyperlinks and I want to send a new sssion variable with its value depending on the row of
the table which is chosen! how can I assign a value to a session variable within a hyperlink of <a href=...>...</a>
?
I will put the code here for you to have a look at! I am very desperate and in a real hurry!
this is the code of this part:
while ($row = mysql_fetch_array($locationq, MYSQL_NUM)) {
$_SESSION['site']=$row[0];
echo "<tr align=\"left\" valign=\"middle\">";
echo "<td>".$row[1]."</td>";
echo "<td height=\"100%\"> </td>";
echo '<td nowrap valign=\"top\"><a href=systems.php?site=' . $row[0] . '>' . $row[2] . "</a></td>";
echo "<td height=\"100%\"> </td>";
.
.
.
this is obviously wrong! Because in each iteration of the loop the value is changed!
I am trying the $_GET variables but this has made problems in the session! in the next page, the queries are not
working properly and I guess it's because of the $_GET variable used!
Any help would be appreciated!
BR
Are you sure you did as Sean mentioned?
if you take this out of your loop
$_SESSION['site']=$row[0];
as you have noticed if this is in the loop it will make the session value equal to the last iteration of the loop.
If you leave this
systems.php?site=' . $row[0] . '
then on your systems.php page set the site value from $_GET to the session like so
$_SESSION['site'] = $_GET['site']
then you will have the proper session value in the targetted script.
There is another possible problem I found in my code!
This is the code:
$locationquery = " SELECT user_site.site_id, site.Client, site.site_name FROM `user_site`, `site` WHERE user_site.user_name='$_SESSION[username]' and site.site_id = user_site.site_id" ;
$locationq = mysql_query($locationquery , $conn);
$locationdailycolorquery = " SELECT user_site.site_id , Count(*) Cnt
FROM `probe_kpi`,
`system_probe` ,
`system`,
`user_site`
WHERE probe_kpi.date = '$_SESSION[startdate]'
AND probe_kpi.kpi_id = 1
AND probe_kpi.probe_id = system_probe.probe_id
AND ((system_probe.system_id = system.system_id
AND system.site_id = user_site.site_id)
AND (user_site.user_name = '$_SESSION[username]'))
AND probe_kpi.kpi_colour = 'RED'
Group By user_site.site_id";
$locationdailycolor = mysql_query($locationdailycolorquery, $conn);
while ($row = mysql_fetch_array($locationq, MYSQL_NUM)) {
echo "<tr align=\"left\" valign=\"middle\">";
echo "<td>".$row[1]."</td>";
echo "<td height=\"100%\"> </td>";
echo '<td nowrap valign=\"top\"><a href=systems.php?site=' . $row[0] . '>' . $row[2] . "</a></td>";
echo "<td height=\"100%\"> </td>";
$row1 = Mysql_fetch_array($locationdailycolor, MYSQL_NUM);
***if ($row1[$row[0]][1]>0) *** {
echo "<div id=\"MyLayer\" style=\"position:absolute; width:229px; height:62px; z-index:1; left: 43px; top: 46px; display:none\"></div>";
echo "<td nowrap valign=\"middle\"><a onClick=\"javascript:Show('Your text goes here! ');\" href=\"#\"><img src=\"images/red.bmp\" border='0'></a>";
}
.
.
.
I have put stars on the part I have problems! Is it ok to do so?
Can we use it this way? May be this is the cause!
[webmasterworld.com...]