lional Posted June 13, 2007 Share Posted June 13, 2007 Hi everyone Need some help here. I am trying to pull the member numbers from a database and create a link for that to another page. I do not what to do it in the methos below because that would require me using the get method from the other page. I do not want the number to be displayed. My thinking was to run an array through the database and pulling all the member numbers and if possible assign those member numbers to a session. Is this possible, and if so what id wrong with my code below Thanks Lional $member_no_out = $row["member_no"]; $fullname = $surnamedb_out . ", " . $firstname_out . " " . $middlename_out; $memno[$key] = $member_no_out; print <<<EXIST <table width="690" border="0"> <tr> <td align="center" valign="top"> <font face="arial" size="2"><b> EXIST; foreach ($memno as $member) ( print <<<EXIST2 <a href="names.php?mem_no=$member</a>Name</b></font> </td> </tr> </table> EXIST2; }} Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/ Share on other sites More sharing options...
trq Posted June 13, 2007 Share Posted June 13, 2007 My thinking was to run an array through the database and pulling all the member numbers and if possible assign those member numbers to a session. How is that going to help you recognise which members data needs to be queried on the next page? Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/#findComment-273918 Share on other sites More sharing options...
lional Posted June 13, 2007 Author Share Posted June 13, 2007 Is there not another way to stop data being shown when it gets sent to the new page , I am fairly new to php so any help will be appreciated Thanks Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/#findComment-273920 Share on other sites More sharing options...
Illusion Posted June 13, 2007 Share Posted June 13, 2007 Your code is not readable, couple of syntax mistakes (like matching braces and closing tags) are there so if possible post the code whatever you used originally. <a href="names.php?mem_no=$member[/url]Name where from the Name come from. Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/#findComment-273922 Share on other sites More sharing options...
Psycho Posted June 13, 2007 Share Posted June 13, 2007 It depends what you mean by "data being shown". If you mean not having the data show int he URL, you could use a miniform form for each name. However, the user could see the data on the first page if they looked at the source code. <form action="names.php" method="POST" name="member_<?php echo $member; ?>"> <input type="hidden" value="<?php echo $member; ?>"> </form> <a href="#" onclick="document.forms['member_<?php echo $member; ?>'].submit();">Name</font> But, I'm curious what your aversion is to having the user see the member id number. The number should have no relevance to the end user. If it does, then you should create a new field to use as the id that does not have any relevance for the user. Another option - which I would not advise - would be to run your page in a frame. Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/#findComment-273929 Share on other sites More sharing options...
lional Posted June 13, 2007 Author Share Posted June 13, 2007 Hi mjdamato The answer to your question is that I am writing an app for an organisation to do end year reports. Some of the members get kicks out of trying to break a program. If they new that was the member number being sent to the next page, could they not manually change that which would send the wrong details through. Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/#findComment-273947 Share on other sites More sharing options...
Psycho Posted June 13, 2007 Share Posted June 13, 2007 Then you are taking the wrong approach. You should validate the data sent. So when the page receives a member id on the query string you woudl first check to see if the id is valid or not. Something like this: <?php $member_no = $_GET['mem_no']; $query = "SELECT * FROM members where mem_no = '".mysql_escape_string($_GET['mem_no'])."'"; $result = mysql_query($query) or die (mysql_error()); if (!mysql_num_rows($result)) { echo "Invalid member number ($member_no)"; } else { //Display the member details } ?> Quote Link to comment https://forums.phpfreaks.com/topic/55424-help-with-arrays/#findComment-274054 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.