Results 1 to 3 of 3
hello -
im having a problem; this array will set but only shows one record from the array. when there are 3 demo data sets(records).
thanks in advance for your ...
- 10-22-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 2
session arrays in php
hello -
im having a problem; this array will set but only shows one record from the array. when there are 3 demo data sets(records).
thanks in advance for your help.
i want to store the variable id in an array and access that array through session id hyper link on the same page. so that when that hyper link is clicked the session id for that record is passed to the next page through sessions.
here is the page code
Code:<?php if (!isset($_SESSION)) { session_start(); } ?> <?php require_once('conn.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $Id = $_SESSION['Id']; //get users id to pass to record $Name = $_SESSION['name']; // display users name $Group = $_SESSION['Group']; // access control group for moderators, members, users $maxRows_List = 10; $pageNum_List = 0; if (isset($_GET['pageNum_List'])) { $pageNum_List = $_GET['pageNum_List']; } $startRow_List = $pageNum_List * $maxRows_List; mysql_select_db($database_List, $List); $query_List = "SELECT * WHERE b.UId1='$UserId'"; $query_limit_List = sprintf("%s LIMIT %d, %d", $query_List, $startRow_List, $maxRows_List); $List = mysql_query($query_limit_List, $List) or die(mysql_error()); $row_List = mysql_fetch_assoc($List); $List_Array = array(); while ($row = mysql_fetch_array($List)) { foreach($row['Id'] as $i=>$val) $List_Array = $val; //return $List_Array; $_SESSION['Id'] = $List_Array; $myList_Array = $_SESSION['Id']; } if (isset($_GET['totalRows_List'])) { $totalRows_List = $_GET['totalRows_List']; } else { $all_List = mysql_query($query_List); $totalRows_List = mysql_num_rows($all_List); } $totalPages_List = ceil($totalRows_List/$maxRows_List)-1; ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ color: #000000; background-color: #0E03D6; } .thrColLiqHdr #container { width: 80%; /* this will create a container 80% of the browser width */ background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: 1px solid #000000; text-align: left; /* this overrides the text-align: center on the body element. */ } .thrColLiqHdr #header { background: #FFFFFF; padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */ } .thrColLiqHdr #header h1 { margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */ padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */ } /* Tips for sidebars: 1. Since we are working in percentages, it's best not to use side padding on the sidebars. It will be added to the width for standards compliant browsers creating an unknown actual width. 2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".thrColLiqHdr #sidebar1 p" rule. 3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns. */ .thrColLiqHdr #sidebar1 { float: left; /* this element must precede in the source order any element you would like it be positioned next to */ width: 22%; /* since this element is floated, a width must be given */ background: #FFFFFF; /* the background color will be displayed for the length of the content in the column, but no further */ padding: 15px 0; /* top and bottom padding create visual space within this div */ } .thrColLiqHdr #sidebar2 { float: right; /* this element must precede in the source order any element you would like it be positioned next to */ width: 23%; /* since this element is floated, a width must be given */ background: #FFFFFF; /* the background color will be displayed for the length of the content in the column, but no further */ padding: 15px 0; /* top and bottom padding create visual space within this div */ } .thrColLiqHdr #sidebar1 p, .thrColLiqHdr #sidebar1 h3, .thrColLiqHdr #sidebar2 p, .thrColLiqHdr #sidebar2 h3 { margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */ margin-right: 10px; } /* Tips for mainContent: 1. the space between the mainContent and sidebars is created with the left and right margins on the mainContent div. 2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 300px or smaller (this includes images). 3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs. */ .thrColLiqHdr #mainContent { margin: 0 24% 0 23.5%; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the sidebar spaces when the content in each sidebar ends. */ } .thrColLiqHdr #footer { padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */ background:#FFFFFF; } .thrColLiqHdr #footer p { margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */ padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */ } /* Miscellaneous classes for reuse */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page The floated element must precede the element it should be next to on the page. */ float: left; margin-right: 8px; } .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain its child floats */ clear:both; height:0; font-size: 1px; line-height: 0px; } #apDiv1 { position:absolute; left:206px; top:83px; width:151px; height:34px; z-index:1; } #apDiv2 { position:absolute; left:363px; top:84px; width:519px; height:37px; z-index:2; } --> </style><!--[if IE]> <style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */ .thrColLiqHdr #sidebar2, .thrColLiqHdr #sidebar1 { padding-top: 30px; } .thrColLiqHdr #mainContent { zoom: 1; padding-top: 15px; } /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */ </style> <![endif]--> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <!--- I had to remove the html header because of new member --> </head> <body class="thrColLiqHdr"> <div id="container"> <div id="header"> <h1> </h1> <p> </p> <p> </p> <!-- end #header --></div> <div id="sidebar1"> <h3> </h3> <!-- show users ratings overall and per list --> <!-- end #sidebar1 --></div> <div id="sidebar2"> <h3> </h3> <!-- display current viewers of user list in space and show count of number of views --> <!-- end #sidebar2 --></div> <div id="mainContent"> <h1> </h1> <blockquote> <table border="1" cellpadding="1" cellspacing="1"> <tr></tr> <caption align="center"> List Click to Edit </caption> <?php do { ?> <tr> <td><a href="list.php"><?php echo $myList_Array['Id']; ?></a></td> <-- this is the column that i want to have access the session id --> <td><?php echo $row_List['Subject'];?></td> <td><?php echo $row_List['Date']; ?></td> </tr> <?php } while($row_List = mysql_fetch_assoc($List)); ?> </table> <h2> </h2> <p> </p> </blockquote> <!-- end #mainContent --></div> <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" /> <div id="footer"> <p>Footer</p> <!-- end #footer --></div> <!-- end #container --></div> </body> </html> <?php mysql_free_result($List); ?>
- 01-11-2010 #2Just Joined!
- Join Date
- Jan 2008
- Posts
- 17
I find your post confusing. Please simplify your example to show only the pieces that directly relate to your question.
Are you trying to pass information from one page to another? That is what sessions are for. Define the session in the pages you wish to share information. Set the variable in one session and it will be available in the subsequent pages after the session is started.
So, with <?php if(!isset($_SESSION)) session_start(); ?> on both pages before using $_SESSION and <?php $_SESSION['id']=42; ?> somewhere in your first page, then <?php echo "$_SESSION['id']"; ?> in your second page will put 42 in your second page.
Are you asking how to use a MySQL table to create an HTML option list which is used to select an id to use on a second page that shows output from a query? Create a query for id and some descriptive field (maybe name) and build a form with your option list. On the second page, use the posted data to build the second query. This is more complex... I'd rather not go through an explanation of how to do this unless it is what you are trying to do.
- 01-11-2010 #3Just Joined!
- Join Date
- Oct 2009
- Posts
- 2
Thanks for your reply this was solved.
It was how i was accessing the url variables on the forward page and how i was passing them from the results page.


Reply With Quote