Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
referencing differnet databases in modify file
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 01/24/11 20:52 
In my module I have States/Counties in 2 differnet dbs what I need to be able to do is when referencing the modify and delete files to be able to reference the state_name by using the county_state_id which matches the state_id currently I have the info to show ascending by county name but I want to show in the ddropdown CountyName(StateName) but to pul state name I need to be able to reference the state from the county state id to refer to the state id which has the state name
Thanks James
databases

Code
State
  state_id
  state_name

County

Code
  county_id
  county_state_id (same as the state_id)
  county_name


CODE

Code
$req = "SELECT county_id, county_name
                  FROM {$jamroom_db['ecmCounties']}
                 ORDER BY county_name ASC";
    $_rt = dbQuery($req,'NUMERIC');
    if (isset($_rt[0]) && is_array($_rt[0])) {
      foreach ($_rt as $_rep) {
        $_sel["{$_rep['county_id']}"] = "{$_rep['county_name']}";
      }
    }
    jmHtmlBegin($language['ecmLocations'][116]);
    jmBodyBegin();
    jmSpanCell($language['ecmLocations'][116],'',30,'html_modify.png');
    jrGetFormNotice();
    jmBeginForm('ecmLocations.php?mode=UpdateCounty');
    jmSelect($language['ecmLocations'][116],'county_id',$_sel);
    jrFormSubmit($language['ecmLocations'][116],false,false,'admin.php?s=section_ecmLocationsSettingsMenu');



_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 01/24/11 22:00 
You would use a JOIN, e.g. a LEFT JOIN:

SELECT c.*, s.*
FROM {$jamroom_db['ecmCounties']} c
LEFT JOIN {$jamroom_db['ecmStates']} s ON s.state_id = c.county_state_id
ORDER BY c.county_name ASC

Make sure you're using the correct state table name.

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 01/26/11 14:29 
Thanks Kyle that worked perfect with a small tweak or 2


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 01/26/11 20:34 
Hello Kyle I am now working on the delete file and trying to get the drop down list to show which it does but it is showingf array as all options instead of showing the county/states what has gone wrong


Code
    // Get existing videos for this profile
    $req = "SELECT c.*, s.*
FROM {$jamroom_db['ecmCounties']} c
LEFT JOIN {$jamroom_db['ecmStates']} s ON s.state_id = c.county_state_id
ORDER BY c.county_name ASC";
    $_rt = dbQuery($req,'NUMERIC');
    if (isset($_rt[0]) && is_array($_rt[0])) {
      foreach ($_rt as $_rep) {
        $_sel["{$_rep['county_id']}"] = "{$_rep['county_name']} -- ({$_rep['state_name']})";
      }
         jmSelect($language['ecmLocations'][122],'county_id',$_rt);
      jrFormSubmit($language['ecmLocations'][122],false,false,false,$language['ecmLocations'][9]);
   
  }  else {
      jmShowLine($language['ecmLocations'][106]);



Code
   
 
 
[26-Jan-2011 21:21:16] PHP Parse error: syntax error, unexpected T_ELSE in /home/mysites/public_html/testsite/modules/ecmLocations/include/views/counties/DeleteCounty.php on line 26
 


I tried to remove the else but it didnt work


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 01/27/11 15:32 
Make sure you balance your if/else statements.

The reason it's showing "array" is because you have this for jmSelect:

jmSelect($language['ecmLocations'][122],'county_id',$_rt);

I think it should be:

jmSelect($language['ecmLocations'][122],'county_id',$_sel);


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 01/27/11 16:30 
perfection thanks


smith.kyle:
Make sure you balance your if/else statements.

The reason it's showing "array" is because you have this for jmSelect:

jmSelect($language['ecmLocations'][122],'county_id',$_rt);

I think it should be:

jmSelect($language['ecmLocations'][122],'county_id',$_sel);



_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.