Re: help make less ugly?

From: Date: Thu, 15 Feb 2001 06:42:17 +0000
Subject: Re: help make less ugly?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39847@lists.php.net to get a copy of this message
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" <andrew@salamander.net> To: <php-general@lists.php.net> 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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#39847) next »