Reply to Re: Linking a

Your name:

Reply:


Posted by Schraalhans Keukenmeester on 05/21/07 22:42

At Sun, 20 May 2007 23:35:06 -0700, satyakaran let his monkeys type:

> On May 18, 7:47 am, bokke <micr...@gmail.com> wrote:
>> Hi - I am using this code
>>
>> echo "<tr><td></td><td id=tablesdirhead>Property Information</td><td
>> id=tablesdirhead width='100'>Agent Name</td><td id=tablesdirhead
>> width='150'>Contact Info</td></tr>\n"; while ($myrow =
>> mysql_fetch_row($result))
>> {
>> $row = 1-$row;
>> $color = ($row==0)?"#F5F5F5":"#F0F8FF";
>> printf("<tr
>> bgcolor=$color><td>%s</td><td>%s</td><td>%s</td><td>%s</
>> td></tr>\n",
>> $myrow[5], $myrow[3], $myrow[0], $myrow[1]);}
>>
>> echo "</table>\n";
>> ?>
>>
>> But would like to give the fourth "$myrow[1]" a PHP link like
>>
>> <a class="dir" href="processformImage.php?action=&ID=<?php echo
>> $row["StoreID"]; ?>">$myrow[1]</a>
>>
>> But can't seem to find anywhere on the web that shows this can even be
>> done
>
> And instead of writing printf();, you should write like this:
>
> echo '<tr>
> <td>'.$myrow[0].'</td>
> <td>'.$myrow[1].'</td>
> </tr>
> ';
>
> Here you can easily format/add anything for any column. echo '<tr>
> <td>'.$myrow[0].'</td>
> <td>'.$myrow[1].'</td>
> <td>'.$myrow[2].'</td>
> <td>'.$myrow[3].'</td>
> <td>'."<a class='dir' href='/index.php?storeID=$row[9]'>
> $myrow[4]</a>.'</td>
> </tr>
> ';
>
>
> satya61229.blogspot.com

Which I personally find a surefire way of introducing many typos.
Using double quotes instead of concatenation and braces around the
$myrow[n] 's is a little less error-prone if you ask me, then sprintf() is
a candidate you may want to consider and better still imho is using
heredoc syntax in these cases. Stepping out of php and surrounding all the
array references with <?PHP ;?> is over the top here.

echo <<<HTML_END
<tr>
<td>$myrow[0]</td>
<td>$myrow[1]</td>
<td>$myrow[2]</td>
<td>$myrow[3]</td>
<td><a class='dir'
href='/index.php?storeID=$row[9]'>$myrow[4]</a></td>
</tr>
HTML_END;

Sh.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация