RE: [PHP-DB] me noob. link if else.. help.

From: Date: Wed, 14 May 2003 10:24:22 +0000
Subject: RE: [PHP-DB] me noob. link if else.. help.
Groups: php.db 
Request: Send a blank email to php-db+get-27736@lists.php.net to get a copy of this message
Hi Paul, Here is a way you can make things easier to read. Use indenting (plus make variable names shorter). <?php // here is sample code but i would use my own db functions instead of these $sql = "SELECT * FROM wherever"; $result = @mysql_query($sql,$conn) or die ("Error in query: ".$sql); while ($row = mysql_fetch_assoc($result)){ extract($row); // make vars from items in array if ($linksLink){ echo $linksName; } else { echo "<a href=\"$linksLink\">$linksName</a>"; } } Adam ?>
ok this worked, but man does it ever look clunky.. i want to thank every one who respond to me on & off list.. if you have other ways you would write the same snippet, please post it. would help me to get a feel for cleaner php. <?php if ($row_rsViewLinks['linksLink'] == NULL) echo $row_rsViewLinks['linksName']; else echo "<a href=\"{$row_rsViewLinks['linksLink']}\">{$row_rsViewLinks['linksName']}</a> " ?> sure oi will have some orderby / groupby questions in a few hours. thanks! -paul


« previous php.db (#27736) next »