You are here: Re: Feedback? « PHP Programming Language « IT news, forums, messages
Re: Feedback?

Posted by J. Frank Parnell on 10/20/07 17:08

On Fri, 19 Oct 2007 11:28:09 GMT, "Kye" <descardo@hotmail.com> wrote:

>As a real pleb with the below being my first actual "real" script written
>from scratch, could anybody please constructively criticise what should be
>changed???
>
>Thanks again for everybody's help

Couple things that I learned along the way, and some of it from the helpful ppl
of this group.

1. Use functions or other code to 'figure out' data first, load it into
variables, then at the end of your page, start echo()ing out the HTML: Send
your $catlist to a function that will load the html into a var:

$list = myListFunc($catlist);
function myListFunc($list){
$html = "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
$html .= '<SELECT name="dropdown">';
$html .= "<OPTION value=3> - Please Select A Category - </OPTION>\n";
while ($row = mysql_fetch_array($list, MYSQL_NUM)){
$html .= "<OPTION value=$row[0]>{$row[1]}</OPTION>\n";
}
$html .= '</SELECT>';
$html .= "<INPUT type='submit' value='Go'>";
$html .= "</form>";
return $html;
}


2. You can avoid a bunch of switch, if/else stuff if you can use the info you
allready have:
instead of:
switch ($row[0]){
case "1":
echo '<img src="images/stars_1.gif">';
break;
etc etc

you can do
echo '<img src="images/stars_'.$row[0].'.gif">';

 

Navigation:

[Reply to this 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

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