Welcome to PHP! Please have exact change. As a general rule, I distrust generated code in PHP, or in HTML. I virtually never use Dreamweaver (or its evil twin, FronPage), as the code it generates is rarely what I want at the quality level I want. Such code is designed for the cut-and-paster. Such code is how we ended up with the same MM_ Javascript functions that everyone used for a decade because DW would autogenerate them for you, despite their not being that good and generating lousy code that is difficult to maintain because the people "writing Javascript" didn't actually have the slightest clue what they're doing. You will get far better code by either writing it by hand yourself or using an existing library that someone else with more experience than you wrote by hand. You will also learn more in the process. (That could be a code library or a framework, to nod to the other thread raging right now, but in either case it's written by a human.) Now, you can certainly study assisted code to see what it's doing and figure out why, but remember that it's generated by a simple, dumb algorithm so it is designed not for speed, readability, or quality, but safety against cut-and-paste spoon-coding. Never use it in actual production. On Tuesday 22 April 2008, revDAVE wrote: > First of all - I know this is an entirely subjective question, and I know > there's no single approach to learning this technology. I'm just looking > for a few hints from seasoned professionals basically whether Dreamweaver > verbose code (at least it looks like that to me at this beginning point) is > all 'needed & necessary'... > > I have a background using ColdFusion, however I am new to php / mySQL. > > I am caught between two learning approaches: > > 1 - I know that generally, it is better to build my knowledge from the > 'bottom up' - coding by hand from books and such etc. - and so far I have > been doing that with php and mySQL. Slowly I am getting there. Php is quite > powerful and impressive. > > 2 - Dreamweaver cs3 is pretty cool. Creating recordsets - dynamic data - > updating records etc. is pretty seductive it seems to work well. > > A few questions: > > One of my issues is that the Dreamweaver code that gets created seems quite > verbose and somewhat complex (like using switch & case in a simple query > listed below...), therefore even harder for this newbie to try to learn > from. My question is this: Is this Dreamweaver code actually all > modern/necessary (vs a 'simple approach') - or is it way over the top? > > Without getting too detailed: > > - If in fact you folks say that most of the DW approach (for those that > have seen it) is 'necessary' & 'the right way to do things' - then I will > be happy to use it and try to figure out some of its complexities . But, if > you think that DW is over the the top ('...I don't use all that suff - I do > a query in just a few lines!') ... then I'll just start with the 'bottom up > - code by hand - do it yourself simple approach'. > > BTW: if anyone wants to see more DW code - email me off-list - I'll be > happy to send more examples... (I don't want to clog up this cool list) > > BTW: I also tried a happy medium - simplifying the DW code - however that > will break its usefulness in DW - and other DW interface items stop > working, so I guess that's not an option right now. > > Interested in your thoughts... Dave > > ------------------------ > > Example get recordset query w DW: > > > <?php require_once('../Connections/weblink.php'); ?> > <?php > if (!function_exists("GetSQLValueString")) { > function GetSQLValueString($theValue, $theType, $theDefinedValue = "", > $theNotDefinedValue = "") > { > $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; > > $theValue = function_exists("mysql_real_escape_string") ? > mysql_real_escape_string($theValue) : mysql_escape_string($theValue); > > switch ($theType) { > case "text": > $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; > break; > case "long": > case "int": > $theValue = ($theValue != "") ? intval($theValue) : "NULL"; > break; > case "double": > $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : > "NULL"; > break; > case "date": > $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; > break; > case "defined": > $theValue = ($theValue != "") ? $theDefinedValue : > $theNotDefinedValue; > break; > } > return $theValue; > } > } > > $colname_get_Recordset1 = "-1"; > if (isset($_SESSION['mem_id'])) { > $colname_get_Recordset1 = $_SESSION['mem_id']; > } > mysql_select_db($database_weblink, $weblink); > $query_get_Recordset1 = sprintf("SELECT * FROM tbl_test WHERE mem_id = %s > ORDER BY mem_id ASC", GetSQLValueString($colname_get_Recordset1, "int")); > $get_Recordset1 = mysql_query($query_get_Recordset1, $weblink) or > die(mysql_error()); > $row_get_Recordset1 = mysql_fetch_assoc($get_Recordset1); > $totalRows_get_Recordset1 = mysql_num_rows($get_Recordset1); > ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> > <title>Untitled Document</title> > </head> > > <body> > </body>Remember > </html> > <?php > mysql_free_result($get_Recordset1); > ?> > > > -- > Thanks - RevDave > Cool @ hosting4days . com > [db-lists] -- Larry Garfield AIM: LOLG42 larry@xxxxxxxxxxxxxxxx ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php