Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java and RAW PHP MySql Data Return Help

    This may sound simple, but I have been pulling my hair out on this. I'm trying to get additional fields to populate based on my selection in my drop-down box from a mysql server. I can't seem to find a way to get other fields populated without messing up. 'sip' populates fine but what steps to get it to poplate other fields. Also getting the code to raw php or html as when I add it to my block on my site it hates php tags (IPS website). Other fields I would like to populate is qluser, restarturl.

    Thank You,
    RJ

    Code:
    <?php
      mysql_connect('123.com','123','123');
      mysql_select_db('123newsite');
      $result=mysql_query("SELECT * FROM serverlist WHERE showinql > 0 ORDER BY sname ASC");
      $options=""; 
      $divs = "";
      $js = "";
      while ($row=mysql_fetch_array($result)) { 
        $id=$row["sid"]; 
        $name=$row["sname"];
        $ip = $row["sip"]; 
        $options.="<option value=\"".$id."\">".$name."</option>";
        $divs.="<div id=\"".$row["sid"]."\"><p>Server IP: ".$row["sip"]."..</p></div>";
        $js.="$('#".$row["sid"]."').hide();"; 
      }  
    ?> 
    
    <?php
      echo "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>";
      echo "<script type='text/javascript'>";
      echo "$(document).ready(function(){";
      
      echo $js;
      
      echo "$(\"#cboServers\").change(function(){";
      echo "$(\"#\" + this.value).show().siblings().hide();";
      echo "});";
      
      echo "$(\"#cboServers\").change();";
      echo "});";
      echo "</script>";
    ?>
    
    <body>
    <select id ="cboServers" name="cboServers" style="width:200px;">
      <?php echo $options ?>
    </select>
    
    <div id="boxes">
      <?php echo $divs ?>
    </div>
    </body>

  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now this works but will not show "sip" on site block. On page refresh u see all "sip's" for a sec then the block shrinks and shows nothing under the dropdown. Changing:

    Code:
      $js.="$('{$row['sid']}').hide();";
    to

    Code:
      $js.="$(#'{$row['sid']}').hide();";
    will populate all rows "sip" values below dropdown, but naturally I only want the one selected "sip" value not the whole field.

    (The below code works fine in a preview box on the backend of the site, but once in a block on the site is where my headaches I mentioned above are)

    Code:
    echo "<div class='maintitle'>{$title}</div>\n"; 
    echo "<div class='ipsBox'>\n"; 
    echo "<div class='ipsBox_container ipsPad'>\n";
    
    mysql_connect('123.com','123','123');
    mysql_select_db('123newsite');
    $result=mysql_query("SELECT sid, sname, sip FROM serverlist WHERE showinql > 0 ORDER BY sname ASC");
    $options="";
    $divs = "";
    $js = "";
    while ($row=mysql_fetch_array($result)) {
      $options.="<option value='{$row['sid']}'>{$row['sname']}</option>";
      $divs.="<div id='{$row['sid']}'><p>{$row['sip']}</p></div>";
      $js.="$('{$row['sid']}').hide();";
    }
    
    echo "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>";
    echo "<script type='text/javascript'>";
    echo "$(document).ready(function(){";
    echo $js;
    echo "$('#cboServers').change(function(){";
    echo "$('#' + this.value).show().siblings().hide();";
    echo "});";
    echo "$('#cboServers').change();";
    echo "});";
    echo "</script>";
    echo "<select id ='cboServers' name='cboServers' style='width:200px;'>";
    echo $options;
    echo "</select>";
    echo "This is where the data should be";
    echo "<div id='boxes'>";
    echo $divs;
    echo "</div>";
    Print "</div>";
    Print "</div>";
    Print "<br />";
    Last edited by RickJames; 01-27-2012 at 03:10 AM.

  • #3
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    Please show us the resulting HTML (from the browser) instead of all the unprocessed PHP

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the reply here is the resulting HTML from firefox (ctrl+u)
    Code:
    <div class='maintitle'></div>
    <div class='ipsBox'>
    <div class='ipsBox_container ipsPad'>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script><script type='text/javascript'>$(document).ready(function(){$('76').hide();$('67').hide();$('69').hide();$('74').hide();$('73').hide();$('3').hide();$('2').hide();$('25').hide();$('8').hide();$('71').hide();$('75').hide();$('10').hide();$('12').hide();$('26').hide();$('54').hide();$('14').hide();$('57').hide();$('16').hide();$('60').hide();$('15').hide();$('70').hide();$('#cboServers').change(function(){$('#' + this.value).show().siblings().hide();});$('#cboServers').change();});</script><select id ='cboServers' name='cboServers' style='width:200px;'><option value='76'>>XI< COD4 MW2 Freeze Srv 2</option><option value='67'>BF3 >XI< 64 man</option><option value='69'>BF3 >XI< Mixed Hardcore</option><option value='74'>Freezetag 1 New York</option><option value='73'>TF2 Server</option><option value='3'>XI COD2 Area 51</option><option value='2'>XI COD2 DM</option><option value='25'>XI COD2 TDM</option><option value='8'>XI COD4 Freeze Tag Srv2</option><option value='71'>XI COD4 MW2 FTag 1.4</option><option value='75'>XI COD4 NEW ACE MOD</option><option value='10'>XI COD4 Zombies</option><option value='12'>XI COD5 DM</option><option value='26'>XI COD5 Modern Weapons</option><option value='54'>XI COD5 Stock Freezetag</option><option value='14'>XI COD5 Vietnam Freezetag</option><option value='57'>XI Crouch</option><option value='16'>XI CW DX10 Hardcore</option><option value='60'>XI CW MechWarrior XL </option><option value='15'>XI CW Zombie Panic</option><option value='70'>Xtreme Idiots DM HC</option></select><div id='boxes'><div id='76'><p>69.9.170.55</p></div><div id='67'><p>173.199.90.38</p></div><div id='69'><p>173.199.92.7</p></div><div id='74'><p>69.9.170.53</p></div><div id='73'><p>68.232.184.218</p></div><div id='3'><p>8.12.23.73</p></div><div id='2'><p>8.9.37.132</p></div><div id='25'><p>68.232.177.84</p></div><div id='8'><p>68.232.166.19</p></div><div id='71'><p>68.232.176.207</p></div><div id='75'><p>69.9.170.54</p></div><div id='10'><p>8.9.8.248</p></div><div id='12'><p>8.12.22.192</p></div><div id='26'><p>63.211.111.138</p></div><div id='54'><p>8.12.22.129</p></div><div id='14'><p>8.12.17.103</p></div><div id='57'><p>173.199.104.204</p></div><div id='16'><p>69.9.170.60</p></div><div id='60'><p>85.17.208.88</p></div><div id='15'><p>87.117.203.93</p></div><div id='70'><p>66.55.142.211</p></div></div></div></div><br />
    Last edited by RickJames; 01-27-2012 at 03:45 PM.

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is some more resulting html (from the blocks before and after the block I am working on) from the main site with the block on it. I had to edit out the exact web addresses as this site is not officially in the public eye yet.

    Code:
    					<li class='clearfix'>
    						<a href='http://www.xxxxx.com/index.php?/user/1970-liquorbox69/' title='View Profile' class='ipsUserPhotoLink left'><img src='http://www.xxxxx.com/public/style_images/Blood/profile/default_large.png' alt="LiquorBox69%s's Photo" class='ipsUserPhoto ipsUserPhoto_mini' /></a>
    						<div class='list_content'>
    							<a href='http://www.xxxxx.com/index.php?/user/1970-liquorbox69/' rel='bookmark' title='LiquorBox69'>LiquorBox69</a>      
    							<p class='desc ipsType_smaller'>
    								<span class='row_data'>Day: 1 / 27 / 1961</span>
    
    							</p>
    						</div>
    					</li>
    				
    				</ul>
    			</div>
    			
    		</div>
    	</div>
    <br />
            <div class='maintitle'>Admin Quick Login 3</div>
    
    <div class='ipsBox'>
    <div class='ipsBox_container ipsPad'>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script><script type='text/javascript'>$(document).ready(function(){$('76').hide();$('67').hide();$('69').hide();$('74').hide();$('73').hide();$('3').hide();$('2').hide();$('25').hide();$('8').hide();$('71').hide();$('75').hide();$('10').hide();$('12').hide();$('26').hide();$('54').hide();$('14').hide();$('57').hide();$('16').hide();$('60').hide();$('15').hide();$('70').hide();$('#cboServers').change(function(){$('#' + this.value).show().siblings().hide();});$('#cboServers').change();});</script><select id ='cboServers' name='cboServers' style='width:200px;'><option value='76'>>XI< COD4 MW2 Freeze Srv 2</option><option value='67'>BF3 >XI< 64 man</option><option value='69'>BF3 >XI< Mixed Hardcore</option><option value='74'>Freezetag 1 New York</option><option value='73'>TF2 Server</option><option value='3'>XI COD2 Area 51</option><option value='2'>XI COD2 DM</option><option value='25'>XI COD2 TDM</option><option value='8'>XI COD4 Freeze Tag Srv2</option><option value='71'>XI COD4 MW2 FTag 1.4</option><option value='75'>XI COD4 NEW ACE MOD</option><option value='10'>XI COD4 Zombies</option><option value='12'>XI COD5 DM</option><option value='26'>XI COD5 Modern Weapons</option><option value='54'>XI COD5 Stock Freezetag</option><option value='14'>XI COD5 Vietnam Freezetag</option><option value='57'>XI Crouch</option><option value='16'>XI CW DX10 Hardcore</option><option value='60'>XI CW MechWarrior XL </option><option value='15'>XI CW Zombie Panic</option><option value='70'>Xtreme Idiots DM HC</option></select><div id='boxes'><div id='76'><p>69.9.170.55</p></div><div id='67'><p>173.199.90.38</p></div><div id='69'><p>173.199.92.7</p></div><div id='74'><p>69.9.170.53</p></div><div id='73'><p>68.232.184.218</p></div><div id='3'><p>8.12.23.73</p></div><div id='2'><p>8.9.37.132</p></div><div id='25'><p>68.232.177.84</p></div><div id='8'><p>68.232.166.19</p></div><div id='71'><p>68.232.176.207</p></div><div id='75'><p>69.9.170.54</p></div><div id='10'><p>8.9.8.248</p></div><div id='12'><p>8.12.22.192</p></div><div id='26'><p>63.211.111.138</p></div><div id='54'><p>8.12.22.129</p></div><div id='14'><p>8.12.17.103</p></div><div id='57'><p>173.199.104.204</p></div><div id='16'><p>69.9.170.60</p></div><div id='60'><p>85.17.208.88</p></div><div id='15'><p>87.117.203.93</p></div><div id='70'><p>66.55.142.211</p></div></div></div></div><br />
    
            <div class='maintitle'>&gt;XI&lt; Server Stats</div>
    <div class='ipsBox'>
    <div class='ipsBox_container ipsPad'>
    <center><a href="http://xxxxx.com/xlrstats/" target="_blank"><img src="/public/style_images/Blood/xlrstats.png" border="0" width="250" height="66" /></a></center>
    </div>
    </div>
    <br />

  • #6
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    Your code is generating rubbish. What is that supposed to mean?

    Code:
    $('57').hide();
    1. id attributes must not begin with a numeric character
    2. The jQuery selector for id attributes starts with a #

  • #7
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    57 is the sid field the main id number for the row used. Its set to autoincrement on the database. the .hide is suppose to hide all other servers info and only show the current selected one.

    Quote Originally Posted by devnull69 View Post
    Your code is generating rubbish. What is that supposed to mean?

    Code:
    $('57').hide();
    1. id attributes must not begin with a numeric character
    2. The jQuery selector for id attributes starts with a #

  • #8
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    changed the following, but now all the ips from the sip field are displaying below the dropdown box:

    Code:
    $js.="$('#{$row['sid']}').hide();";
    Code:
    echo "<div class='maintitle'>{$title}</div>\n"; 
    echo "<div class='ipsBox'>\n"; 
    echo "<div class='ipsBox_container ipsPad'>\n";
    
    mysql_connect('123.com','123','123');
    mysql_select_db('123inewsite');
    $result=mysql_query("SELECT sid, sname, sip FROM serverlist WHERE showinql > 0 ORDER BY sname ASC");
    $options="";
    $divs = "";
    $js = "";
    while ($row=mysql_fetch_array($result)) {
      $options.="<option value='{$row['sid']}'>{$row['sname']}</option>";
      $divs.="<div id='{$row['sid']}'><p>{$row['sip']}</p></div>";
      $js.="$('#{$row['sid']}').hide();";
    }
    echo "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>";
    echo "<script type='text/javascript'>";
    echo "$(document).ready(function(){";
    echo $js;
    echo "$('#cboServers').change(function(){";
    echo "$('#' + this.value).show().siblings().hide();";
    echo "});";
    echo "$('#cboServers').change();";
    echo "});";
    echo "</script>";
    echo "<select id ='cboServers' name='cboServers' style='width:200px;'>";
    echo $options;
    echo "</select>";
    echo "<div id='boxes'>";
    echo $divs;
    echo "</div>";
    echo "</div>";
    echo "</div>";
    echo "<br />";
    with the following html output

    Code:
    <div class='maintitle'>Admin Quick Login 3</div>
    
    <div class='ipsBox'>
    <div class='ipsBox_container ipsPad'>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script><script type='text/javascript'>$(document).ready(function(){$('#76').hide();$('#67').hide();$('#69').hide();$('#74').hide();$('#73').hide();$('#3').hide();$('#2').hide();$('#25').hide();$('#8').hide();$('#71').hide();$('#75').hide();$('#10').hide();$('#12').hide();$('#26').hide();$('#54').hide();$('#14').hide();$('#57').hide();$('#16').hide();$('#60').hide();$('#15').hide();$('#70').hide();$('#cboServers').change(function(){$('#' + this.value).show().siblings().hide();});$('#cboServers').change();});</script><select id ='cboServers' name='cboServers' style='width:200px;'><option value='76'>>XI< COD4 MW2 Freeze Srv 2</option><option value='67'>BF3 >XI< 64 man</option><option value='69'>BF3 >XI< Mixed Hardcore</option><option value='74'>Freezetag 1 New York</option><option value='73'>TF2 Server</option><option value='3'>XI COD2 Area 51</option><option value='2'>XI COD2 DM</option><option value='25'>XI COD2 TDM</option><option value='8'>XI COD4 Freeze Tag Srv2</option><option value='71'>XI COD4 MW2 FTag 1.4</option><option value='75'>XI COD4 NEW ACE MOD</option><option value='10'>XI COD4 Zombies</option><option value='12'>XI COD5 DM</option><option value='26'>XI COD5 Modern Weapons</option><option value='54'>XI COD5 Stock Freezetag</option><option value='14'>XI COD5 Vietnam Freezetag</option><option value='57'>XI Crouch</option><option value='16'>XI CW DX10 Hardcore</option><option value='60'>XI CW MechWarrior XL </option><option value='15'>XI CW Zombie Panic</option><option value='70'>Xtreme Idiots DM HC</option></select><div id='boxes'><div id='76'><p>69.9.170.55</p></div><div id='67'><p>173.199.90.38</p></div><div id='69'><p>173.199.92.7</p></div><div id='74'><p>69.9.170.53</p></div><div id='73'><p>68.232.184.218</p></div><div id='3'><p>8.12.23.73</p></div><div id='2'><p>8.9.37.132</p></div><div id='25'><p>68.232.177.84</p></div><div id='8'><p>68.232.166.19</p></div><div id='71'><p>68.232.176.207</p></div><div id='75'><p>69.9.170.54</p></div><div id='10'><p>8.9.8.248</p></div><div id='12'><p>8.12.22.192</p></div><div id='26'><p>63.211.111.138</p></div><div id='54'><p>8.12.22.129</p></div><div id='14'><p>8.12.17.103</p></div><div id='57'><p>173.199.104.204</p></div><div id='16'><p>69.9.170.60</p></div><div id='60'><p>85.17.208.88</p></div><div id='15'><p>87.117.203.93</p></div><div id='70'><p>66.55.142.211</p></div></div></div></div><br />
    Last edited by RickJames; 01-27-2012 at 07:02 PM.

  • #9
    New to the CF scene
    Join Date
    Jan 2012
    Location
    WI
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And here is even a better view, but still cant figure out why it works locally and on the backend but not on the frontend of the site. Still populates all ips from the "sip" field instead of the one selected.

    Code:
    echo "<div class='maintitle'>{$title}</div>\n"; 
    echo "<div class='ipsBox'>\n"; 
    echo "<div class='ipsBox_container ipsPad'>\n";
    
    mysql_connect('123.com','123','123');
    mysql_select_db('123newsite');
    $result=mysql_query("SELECT sid, sname, sip FROM serverlist WHERE showinql > 0 ORDER BY sname ASC");
    $options="";
    $divs = "";
    $js = "";
    while ($row=mysql_fetch_array($result)) {
      $options.="<option value='{$row['sid']}'>{$row['sname']}</option>\n";
      $divs.="<div id='a{$row['sid']}'><p>{$row['sip']}</p></div>\n";
      $js.="$('#a{$row['sid']}').hide();\n";
    }
    
    echo "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>\n";
    echo "<script type='text/javascript'>\n";
    echo "$(document).ready(function(){\n";
    echo $js;
    echo "$('#cboServers').change(function(){\n";
    echo "$('#a' + this.value).show().siblings().hide();\n";
    echo "});\n";
    echo "$('#cboServers').change();\n";
    echo "});\n";
    echo "</script>\n";
    echo "<select id ='cboServers' name='cboServers' style='width:200px;'>\n";
    echo $options;
    echo "</select>\n";
    echo "<div id='boxes'>\n";
    echo $divs;
    echo "</div>\n";
    echo "</div>\n";
    echo "</div>\n";
    echo "<br />\n";
    Code:
    <div class='maintitle'>Admin Quick Login 3</div>
    
    <div class='ipsBox'>
    <div class='ipsBox_container ipsPad'>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
    <script type='text/javascript'>
    $(document).ready(function(){
    $('#a76').hide();
    $('#a67').hide();
    $('#a69').hide();
    $('#a74').hide();
    $('#a73').hide();
    $('#a3').hide();
    $('#a2').hide();
    $('#a25').hide();
    $('#a8').hide();
    $('#a71').hide();
    $('#a75').hide();
    $('#a10').hide();
    $('#a12').hide();
    $('#a26').hide();
    $('#a54').hide();
    $('#a14').hide();
    $('#a57').hide();
    $('#a16').hide();
    $('#a60').hide();
    $('#a15').hide();
    $('#a70').hide();
    $('#cboServers').change(function(){
    $('#a' + this.value).show().siblings().hide();
    });
    $('#cboServers').change();
    });
    </script>
    <select id ='cboServers' name='cboServers' style='width:200px;'>
    <option value='76'>>XI< COD4 MW2 Freeze Srv 2</option>
    <option value='67'>BF3 >XI< 64 man</option>
    <option value='69'>BF3 >XI< Mixed Hardcore</option>
    <option value='74'>Freezetag 1 New York</option>
    
    <option value='73'>TF2 Server</option>
    <option value='3'>XI COD2 Area 51</option>
    <option value='2'>XI COD2 DM</option>
    <option value='25'>XI COD2 TDM</option>
    <option value='8'>XI COD4 Freeze Tag Srv2</option>
    <option value='71'>XI COD4 MW2 FTag 1.4</option>
    <option value='75'>XI COD4 NEW ACE MOD</option>
    <option value='10'>XI COD4 Zombies</option>
    <option value='12'>XI COD5 DM</option>
    
    <option value='26'>XI COD5 Modern Weapons</option>
    <option value='54'>XI COD5 Stock Freezetag</option>
    <option value='14'>XI COD5 Vietnam Freezetag</option>
    <option value='57'>XI Crouch</option>
    <option value='16'>XI CW DX10 Hardcore</option>
    <option value='60'>XI CW MechWarrior XL </option>
    <option value='15'>XI CW Zombie Panic</option>
    <option value='70'>Xtreme Idiots DM HC</option>
    </select>
    
    <div id='boxes'>
    <div id='a76'><p>69.9.170.55</p></div>
    <div id='a67'><p>173.199.90.38</p></div>
    <div id='a69'><p>173.199.92.7</p></div>
    <div id='a74'><p>69.9.170.53</p></div>
    <div id='a73'><p>68.232.184.218</p></div>
    <div id='a3'><p>8.12.23.73</p></div>
    <div id='a2'><p>8.9.37.132</p></div>
    <div id='a25'><p>68.232.177.84</p></div>
    
    <div id='a8'><p>68.232.166.19</p></div>
    <div id='a71'><p>68.232.176.207</p></div>
    <div id='a75'><p>69.9.170.54</p></div>
    <div id='a10'><p>8.9.8.248</p></div>
    <div id='a12'><p>8.12.22.192</p></div>
    <div id='a26'><p>63.211.111.138</p></div>
    <div id='a54'><p>8.12.22.129</p></div>
    <div id='a14'><p>8.12.17.103</p></div>
    <div id='a57'><p>173.199.104.204</p></div>
    
    <div id='a16'><p>69.9.170.60</p></div>
    <div id='a60'><p>85.17.208.88</p></div>
    <div id='a15'><p>87.117.203.93</p></div>
    <div id='a70'><p>66.55.142.211</p></div>
    </div>
    </div>
    </div>
    <br />


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •