RE: [PHP-DB] need some help...
| From: | Shrock, Court | Date: | Wed, 03 Apr 2002 00:54:06 +0000 |
| Subject: | RE: [PHP-DB] need some help... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-18141@lists.php.net to get a copy of this message | ||
If you want your output to validate xhtml, you had better make sure that
your html looks like:
<a href="link.php">Link</a>
and NOT:
<a href='link.php'>Link</a>
> -----Original Message-----
> From: Jonathan Hilgeman [mailto:JHilgeman@ecx.com]
> Sent: Tuesday, April 02, 2002 4:52 PM
> To: 'szii@sziisoft.com'
> Cc: 'php-db@lists.php.net'
> Subject: RE: [PHP-DB] need some help...
>
>
> Thank you. Someone else exists who has the sense of mind to use single
> quotes. I hate looking at other people's code that has tons
> of \"s in it.
>
> - Jonathan
>
> -----Original Message-----
> From: szii@sziisoft.com [mailto:szii@sziisoft.com]
> Sent: Tuesday, April 02, 2002 5:00 PM
> To: php-db@lists.php.net
> 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
>