Re: Feedback?
- From: J. Frank Parnell <pos@xxxxxxxxxxxx>
- Date: Sat, 20 Oct 2007 10:08:57 -0700
On Fri, 19 Oct 2007 11:28:09 GMT, "Kye" <descardo@xxxxxxxxxxx> 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">';
.
- References:
- Feedback?
- From: Kye
- Feedback?
- Prev by Date: Re: HEREDOC help, going quietly nuts
- Next by Date: Re: Feedback?
- Previous by thread: Re: Feedback?
- Next by thread: Re: Feedback?
- Index(es):
Relevant Pages
|