Re: Feedback?



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">';


.



Relevant Pages

  • Re: Unhandled exception in MSHTML.DLL
    ... > always crashes when its CHtmlView view started to load a specific local ... > html page, please let me know if I have misunderstood anything. ... > program crashes at. ... All 3 files load just fine in a regular browser. ...
    (microsoft.public.vc.mfc)
  • Re: Lost formatting in browser view source
    ... At the same time your html pages without php-code are processed by php. ... If you are concerned about users links and bookmarks to break, you have the nice option in apache to rewrite rules, if they try to load a "missing" html page, redirect them to a php file with the same name. ... run your editor, load 100 pages, use find/replace to change the address ...
    (alt.php)
  • Re: Another basic question: How to call and show one Web Form from another Web Form?
    ... > I've got an ASP.NET Form (Web Form) that contains various info/controls. ... > ' What do I use to load MyWebForm in the current browser window? ... am I being unrealistic in wanting to NOT keep resorting back to HTML ... I find the HTML syntax mind boggling, ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: McAfee: Microsoft completely unrealistic on Vista
    ... Yet it also doesn't allow any other attachments to load -- which is the ... It does send in HTML by default, which encourages others to permit HTML ... or do some of them have their own rendering engine? ...
    (comp.sys.mac.advocacy)
  • Re: Poor perfomance with Spreadsheet OWC 10 with more than 200 columns
    ... then i load into the spreadsheet using XMLLOAD. ... HTML portion is what is slowing it down. ... > OWC Version: 10.0.0.2621 ... >>> to design the html table, reading from a Recordset. ...
    (microsoft.public.office.developer.web.components)