Re: Having trouble understanding how to manage arrays

From: Date: Tue, 11 Jun 2002 05:42:50 +0000
Subject: Re: Having trouble understanding how to manage arrays
Groups: php.db 
Request: Send a blank email to php-db+get-19729@lists.php.net to get a copy of this message
Hi Bill, Looks like you're making it hard for yourself, by querying the database for each record found. Here is some code which should make your life easier. Of course, I have developed functions which would turn the following code into 10 or so lines, but this should work for your situation. Adam <?php /* Connecting, selecting database */ $link = mysql_connect("192.168.0.112", "root", "") or die("Could not connect"); print "Connected successfully"; mysql_select_db("dgdrivers") or die("Could not select database"); /* Performing SQL query */ $query = "SELECT type, manname, manlink FROM man_links"; $result = mysql_query($query) or die("Query failed"); ?> <table border="0" cellspacing="0" cellpadding="5"> <?php while ($row = mysql_fetch_array($result)){ ?> <tr> <td><?= $row["type"] ?></td> <td><a href="<?= $row["manlink"] ?>"><?= $row["manname"] ?></a></td> </tr> <?php } ?> </table> <?php /* Free resultset */ mysql_free_result($result); /* Closing connection */ mysql_close($link); ?>

« previous php.db (#19729) next »