mysql - Passing an array between several php pages -
i'm working on project use database store books information. @ first step, put book id database array, , use array create image list. here's program generate variables $previous_index & $next_index array $book_list, $book_list store id of books in whole database:
while($row = mysqli_fetch_array($sql)) { $current_index = find_array_index($current_id,$book_list); $next_index = $current_index + 1; $previous_index = $current_index - 1; // previous key / returns false if result found @ first key if ($previous_index >= 0) { $previous_id = $book_list[$previous_index]; } else { $previous_id = 'null'; } // previous key / returns false if result found @ first key if ($next_index <= sizeof($book_list)) { $next_id = $g_list[$next_index]; } else { $next_id = 'null'; } when user click image list, guided page, detail page, shows details of book, price, author...... , also, i've designed 2 buttons, previous , next, users can move next book without going main list. tried pass array $book_list detail page using serialize method:
// pass global array between pages $global_array = urlencode(serialize($book_list)); $link = 'book_detail.php?id=' . $current_id . '&array=' . $global_array ; and content of array in detail page:
print_r(unserialize(urldecode(stripslashes($_get['array'])))); however, shows nothing in print_r function.
is there wrong program ? , there alternative way fulfil requirement, without passing array between several php pages ?
grateful if can give me hints.
do this...
<?php session_start(); then create array inside session variable
$_session['bookarray'] = '...'; on other pages accessible long call
session_start() at top of page.
Comments
Post a Comment