Awesome, thanks a ton! Thanks! -------------------------------------------- -Alex "Big Al" Behrens E-mail: [EMAIL PROTECTED] Urgent E-mail: [EMAIL PROTECTED] (Please be brief!) Phone: 651-482-8779 Cell: 651-329-4187 Fax: 651-482-1391 ICQ: 3969599 Owner of the 3D-Unlimited Network: http://www.3d-unlimited.com Send News: [EMAIL PROTECTED] ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, April 02, 2002 7:00 PM Subject: Re: [PHP-DB] need some help...
> Not really a database question, but why not... > > Step 1: Clean up the code... > a) Convert all double-quote to single quotes in the HTML portion. > I usually use doubles for PHP and singles for HTML. I hate > having to escape quotes. > b) Use of spacing and indentation. > > old > ********************************************** > <div align="left"> > <table border="0" cellpadding="0" cellspacing="0" width="95%"> > <tr> > <td width="100%"><p> > <font face="Tahoma, Verdana, Arial, Helvetica" size="1"><img > src="/images/menu-reviews.gif" width="137" height="20"><br><br><?php > $db = mysql_connect( "db", "******", "******"); > mysql_select_db( "net3dual_reviews",$db); > $r = mysql_query("SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7"); > $max = mysql_query("select max(num) from hwureviews",$db); > while($a=mysql_fetch_array($r)) { > printf (" <a href=\"%s\"><img src=\"%s\" > border=\"0\"></a><br> - <a > href=\"%s\">%s</a><br><br>",$a["url"],$a["picurl"],$a["picurl"],$a["title"]) > ; > } > ?> > </font></p> > </td> > </tr> > </table> > </div> > ********************************************** > > > > new > ********************************************** > <div align='left'> > <table border='0' cellpadding='0' cellspacing='0' width='95%'> > <tr> > <td width='100%'><p> > <font face='Tahoma, Verdana, Arial, Helvetica' size='1'> > <img src='/images/menu-reviews.gif' width='137' height='20'><br><br> > <?php > $db = mysql_connect( "'db", "******", "******"); > mysql_select_db( "net3dual_reviews",$db); > $r = mysql_query("SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7"); > $max = mysql_query("select max(num) from hwureviews",$db); > while($a=mysql_fetch_array($r)) > { > printf (" <a href=\"%s\"><img src=\"%s\" > border='0'></a><br> - > <a href='%s'>%s</a><br><br>",$a["url"],$a["picurl"],$a["picurl"],$a["title"]); > } > ?> > </font></p> > </td> > </tr> > </table> > </div> > ********************************************** > > Since you have to put a string value, assign all output to a single string called $output. > Note that I moved your printf() to an echo, and simplified your output string by preassigning > variables. An extra step, but greatly enhances readability and maintenance... > Also remember that the ".=" is an append operator whereas "=" is assignment. > > even newer > ********************************************** > // Assign the stuff before... > $output = > " > <div align='left'> > <table border='0' cellpadding='0' cellspacing='0' width='95%'> > <tr> > <td width='100%'><p> > <font face='Tahoma, Verdana, Arial, Helvetica' size='1'> > <img src='/images/menu-reviews.gif' width='137' height='20'><br><br> > "; > <?php > $db = mysql_connect( "'db", "******", "******"); > mysql_select_db( "net3dual_reviews",$db); > $r = mysql_query("SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7"); > $max = mysql_query("select max(num) from hwureviews",$db); > while($a=mysql_fetch_array($r)) > { > $url = $a["url"]; > $picurl = $a["picurl"]; > $title = $a["title"]; > > // add in each link to the review > $output .= " > <a href='$url'> > <img src='$picurl' border='0'> > </a> > <br> - > <a href='$picurl'> > $title > </a> > <br><br>"; > } > ?> > // finish the structure HTML > $output .= " > </font></p> > </td> > </tr> > </table> > </div> > "; > > // Now fopen() the file, fputs the $output, and fclose() the file. > ********************************************** > http://www.php.net/manual/en/function.fopen.php > http://www.php.net/manual/en/function.fputs.php > http://www.php.net/manual/en/function.fclose.php > > Party on! > > -Szii > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php