Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
janiceP
Starting Member
2 Posts |
Posted - 2004-03-01 : 13:16:12
|
Dear All!I am a first-timer here. I am glad to have discovered this forum.I was searching for some information on php and my search brought me here.I am hoping that I can fortunate to have someone help me.I found a php code (only code I could find that would help me accomplish my requirement).Problem is I know very little php.Can someone please help me translate this bit of code.You can just translate any part of it that you understand.Thanks in advance for your help.</head><body><div align="center"><?php#include("db_functions.php");require_once("DB.php");include("connect.php");echo $action;if ($opener == 'Map') { $sql = "select str_num, name, x(the_geom), y(the_geom), feat_type from tbl where geo_oid = $geo_oid"; $row = $db->getRow($sql); $str_num = $row[0]; $str_name = $row[1]; $x = $row[2]; $y = $row[3]; $feat_type = $row[4]; if ($feat_type == 'driv') {$feat_type_label = 'Driveway';} if ($feat_type == 'stru') {$feat_type_label = 'Structure';} $alias_str_name = $str_name; $alias_str_num = $str_num; $alias_start = date("Y-m-d"); $alias_type = 'Address Change';}if ($action == 'Edit') { echo "select geo_oid, str_number, str_numext, name, alias_type, start_date, end_date, feat_type from tbl_alias where id = $id"; $cur = $conn->Parse("select geo_oid, str_number, str_numext, name, alias_type, start_date, end_date, feat_type from tbl_alias where id = $id",0); $cur->Execute(); while ($cur->fetch()) { $geo_oid = $cur->GetColumn(0); $alias_str_num = $cur->GetColumn(1); $alias_str_numext = $cur->GetColumn(2); $alias_str_name = $cur->GetColumn(3); $alias_type = $cur->GetColumn(4); $alias_start = $cur->GetColumn(5); $alias_end = $cur->GetColumn(6); $feat_type = $cur->GetColumn(7); } $cur->Close;}if ($action == 'Add') { #echo "insert into daccess_alias values (nextval('daccess_alias_seq'), $geo_oid)"; $cur = $conn->Parse("insert into tbl_alias values (nextval('tbl_alias_seq'), $geo_oid)",0); $cur->Execute(); $cur->Close; $cur = $conn->Parse("select currval('tbl_alias_seq')",0); $cur->Execute(); $row = $cur->fetch(); $id = $cur->GetColumn(0); $cur->Close;}if ($action == 'Save') { $entry_date = date("d M Y"); if ($alias_start == '') {$alias_start = "null";} else {$alias_start = "to_date('$alias_start','YYYY-mm-dd')";} $insert = "insert into tbl_alias (id, geo_oid, str_number, str_numext, str_num, name, alias_type, start_date, the_geom, entry_date, feat_type) values (nextval('tbl_alias_seq'), $geo_oid, $alias_str_num, upper('$alias_str_numext'), trim(to_char($alias_str_num,'999999999999')), upper('$alias_str_name'), '$alias_type', $alias_start, ('POINT($x $y)'::GEOMETRY), to_date('$entry_date', 'DD Mon YYYY'), '$feat_type')"; echo $insert; $result = $db->query($insert); if (DB::isError($result)) { die ($result->getMessage()); } echo "<script language=\"Javascript\">closeWin();</script>"; }echo "Enter address change or alias for $str_num $str_name"; |
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2004-03-01 : 19:00:25
|
ugh. Like I needed a reminder about why I don't do PHP Maybe ask this on a more general web developer list, I don't think there are many PHP people here. Also, maybe stating your requirements would help. I know enough about PHP to be able to say that if I knew what you were trying to achive, I wouldn't do it that way.Damian |
|
|
janiceP
Starting Member
2 Posts |
Posted - 2004-03-02 : 12:07:35
|
hi Damian,I understand and I appreciate it.Believe or not, of all the code I pasted, the only part I need help on is these 2 parts:geo_oid = $geo_oid";$row = $db->getRow($sql); $str_num = $row[0];$str_name = $row[1];$x = $row[2];$y = $row[3];$feat_type = $row[4];if ($feat_type == 'driv') {$feat_type_label = 'Driveway';}if ($feat_type == 'stru') {$feat_type_label = 'Structure';}$alias_str_name = $str_name;$alias_str_num = $str_num;$alias_start = date("Y-m-d");$alias_type = 'Address Change'; //This one above uses the $db object which must be instantiated in one of the include files to fetch a row based off the above SQL statement.Question is how do I fetch a row based off of a sql statement?and this:echo $insert;$result = $db->query($insert);if (DB::isError($result)) {die ($result->getMessage());}The last part I can live with because I think is part of the DB inlcude file which I can disregard.I only included it here just in case I need it in the future.I spent last night translating most of it. |
|
|
|
|
|
|
|