try this instead:
session_start();
.
.
.
if (mysql_num_rows($_query)) {
$_rec = mysql_fetch_array($_query);
if (!isset($_SESSION["bkmks"]) ||
!in_array($_rec, $_SESSION["bkmks"]) {
$_SESSION["bkmks"][] = $_rec;
}
else {
echo "Already exist.";
}
}
to test:
echo "<pre>";
print_r($_SESSION["bkmks"]);
echo "</pre>";
p.s. assuming you are using php 4.1 or above
Ricky wrote:
> Hello everybody I'd like to make a page in which the results shown can
> be bookmarked by clicking a button aside each of them.
> Actually first it should check if the session is open already ... Then
> if that item(that comes from a query to a MySQL table) has been
> registered already, finally it registers all the variables in a
> multidimensional array.
>
> this is the code:
>
> session_start();
>
> if(!session_is_registered("bkmks"))
>
> {session_register("bkmks")||die("WE GOT PROBLEMS MAN");
> $bkmks = array(array(tab=>$tab, id=>$id, url=>$url, nome=>$nome,
> ind=>$ind, com=>$com, pv=>$pv, tel=>$tel, chi=>$chi));
>
> print "<html><body >Your choice has been
> stored</body></html>";
>
> }
>
> else
>
> {
>
>
> foreach($bkmks as $v)
>
> {
>
> if(($v[tab]==$tab)&&($v[id]==$id)){
> print "<html><body You have already chosen this item</body></html>";exit;
>
> }
>
> }
>
> $bkmks[][tab]=$tab;
>
> $bkmks[][id]=$id;
>
> $bkmks[][url]=$url;
>
> $bkmks[][nome]=$nome;
>
> $bkmks[][ind]=$ind;
>
> $bkmks[][com]=$com;
>
> $bkmks[][pv]=$pv;
>
> $bkmks[][tel]=$tel;
>
> $bkmks[][chi]=$chi;
> print "<html><body>Your choice has been
> stored</body></html>";
>
> }
>
> It doesn't work! I can't figure out why.
> It starts storing fine and then it seems messing up with values so it
> recognises as already stored only the variables of my first choice (the
> value stored at bkmks[0])... I tried to print values stored in the
> array: the output is a mess I don't know why!
>
> Thanks a lot !
> Bye.
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php