try using serialize() and unserialize()

but if you have a large amount of data, you would be better off using
sessions.

hope that helps

best regards

Ankur Verma
HCL Technologies
A1CD, Sec -16
Noida, UP
India

----- Original Message -----
From: "Andrew" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 15, 2001 3:49 AM
Subject: [PHP] help make less ugly?


> Hi,
>
> can anyone suggest how to make this less hackish - perhaps preserving the
> array across page iterations somehow?
>
> I'm storing image path info in MySQL and creating an array from the result
> set, so I can build hrefs to the other pics as well as populate the img
tag.
> This page calls itself to provide a running display of the current pic and
> the links to other pics.
> To preserve the passed href value, I've had to create the array TWICE as
> well as map the passed variable to another name to preserve it.
>
> tia,
> andrew
>
> <?php
> file://begin database connection stuff
> include("db_connect_params.inc");  file://all relevant database variables
> $sql="select path from PHOTO where pid =1";  file://obvious
> $link_id = mysql_connect($host, $usr, $pass); file://get connection handle
> $result = mysql_db_query($database, $sql, $link_id) or die("no result");
>
> file://begin hackishness
> if (!isset($i))
> {
>  $i = 1; file://initialize counter
>  while($row=mysql_fetch_array($result)) file://read rows of picture paths
into an
> array
>    {
>     extract($row);
>     $displayed[$i]=$path;
>     echo "<a href=\"$PHP_SELF?i=$i\">$i</a>&nbsp&nbsp";
>     $i++;
>    }
>
>  echo "<img src =\"$displayed[1]\"></img><br>"; file://use first row pic
as
> default
>
> } else {
>
>      $ii = $i; file://preserve passed pic selection value
>      $i = 1; file://re-initialize counter
>      while($row=mysql_fetch_array($result)) file://read rows of picture
paths
> into an array
>    {
>     extract($row);
>     $displayed[$i]=$path;
>     echo "<a href=\"$PHP_SELF?i=$i\">$i</a>&nbsp&nbsp";
>     $i++;
>    }
>
>      echo "<img src =\"$displayed[$ii]\"></img><br>"; file://use passed
pic
>
>        }
>
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to