/    Sign up×
Community /Pin to ProfileBookmark

help with arrays

I have a page that pulls info and displays it based on search criteria, am using pagination as well. You then click on that link and it takes you to a page with more details. On this page I want the options Previous & Next.

I am trying to pass an array from page 1 to page 2 but not really sure how. I am believe I need to serialize my array on page 1 and then unserialize it on page 2, then use that info to pull more details out of the db

Can someone help me with this? I don’t know where I would “serialzie” it or what to pass

[code=php]$num_rows = mysql_num_rows($result);

while ($r=mysql_fetch_array($result)){
$userID=$r[“userID”];

if (0 < $c && 0 == $c % $cells_wide){
<a href=’profile.php?userID=$r[userID]’><div id=’name’>$userID</div> </a>”;

$c++;
} // end of while

echo ” <a href=’test1.php?userID=$r[userID]’>UserIDs </a> “;
[/code]

I’ve read the serialize info of the PHP Manual and still very confused.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@harklyauthorJul 28.2010 — I've serialized in

[CODE]$num_rows = mysql_num_rows($result);

while ($r=mysql_fetch_array($result)){
$userID=$r["userID"];
$serialized = serialize($userID);
if (0 < $c && 0 == $c % $cells_wide){
<a href='profile.php?userID=$r[userID]'><div id='name'>$userID</div> </a>";

$c++;
} // end of while
mysql_free_result( $result );
echo " <a href='test1.php?userID=$serialized'>UserIDs </a> "; [/CODE]


and am passing to other page

if this the correct way to unserialize it??

[code=php]$userID=$_GET["userID"];
echo "$userID <br><br>";

$unserialized = unserialize(serialize($userID));[/code]


and what I am getting is
a:12:{i:0;s:6:"harkly";i:1;s:6:"nester";i:2;s:5:"test1";i:3;s:5:"test2";i:4;s:5:"test3";i:5;s:5:"test5";i:6;s:6:"test66";i:7;s:5:"test8";i:8;s:5:"test9";i:9;s:6:"test10";i:10;s:6:"test12";i:11;s:6:"test11";} [/QUOTE]

how do I get the data I need out of that??
Copy linkTweet thisAlerts:
@Web_IntuitJul 28.2010 — You should urlencode() the serialized string before passing it to the next page.

On the next page you should have:
<i>
</i>$unserialized = unserialize( urldecode($_GET['userID']) );
×

Success!

Help @harkly spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...