Jump to content

jay7981

Members
  • Posts

    175
  • Joined

  • Last visited

Everything posted by jay7981

  1. ok then why isnt it working correctly, its renaming all the names in sm_admins to what ever is in the form ... if i have this in sm_admins already ... example: id identity name 1 2929292 bob 2 3965930 tom 3 8563345 chris 4 7834564 pete when the name of bob is changed to eric i get this in table example: id identity name 1 2929292 eric 2 3965930 eric 3 8563345 eric 4 7834564 eric
  2. SET a.name = '" . mysql_real_escape_string($name) . "', b.group_id = '" . mysql_real_escape_string($group) . "' shouldnt that update both the name colomn in sm_admins and the group_id in sm_admins_groups?
  3. ok now i am stuck again, using the above query it displays the information correctly, however when i change it to an UPDATE: i am updating the group that they are assigned to(housed in the "sm_admins_groups" table) and possible thier name housed in the "sm_admins" table), using the below code it is changing all the names in the $smadmgrp_table to the same name. When i do print_r($_POST); to see what info is actually being passed from the form i get Array ( [name] => BOB [group] => 4 [admin_id] => 66 [button] => Submit ) the form looks like this <?php $db = mysql_connect ($hostname, $username, $password) or die ('Failed to connect to database: ' . mysql_error()); mysql_select_db ($database); $query = "SELECT b.id, a.name, a.authid, a.rank, c.group_id AS grp_id, c.admin_id AS admin_id, d.immunity_level, d.flags FROM bioclan.clan_members a INNER JOIN bioclan.sm_admins b ON a.authid = b.identity INNER JOIN bioclan.sm_admins_groups c ON b.id = c.admin_id INNER JOIN bioclan.sm_groups d ON c.group_id = d.id WHERE b.identity='" . $_POST['auth'] . "'"; $result = mysql_query($query) or die ("Cannot query table " . mysql_error()); $row = mysql_fetch_assoc($result); $auth = $row['authid']; $name = $row['name']; $group = $row['grp_id']; $flags = $row['flags']; $immune = $row['immunity_level']; $id = $row['id']; $admin_id = $row['admin_id']; mysql_free_result($result); mysql_close($db); ?> <form action="sm_update.php" method="post"> <table width="100%"> <tr> <td> </td> <td colspan="2"> </td> </tr> <tr> <td><div align="right">SteamID:</div></td> <td colspan="2"><div align="left"> <?php echo "$auth";?> </div></td> </tr> <tr> <td><div align="right">Name:</div></td> <td colspan="2"><div align="left"> <input name="name" type="text" value="<?php echo "$name";?>" /> </div></td> </tr> <tr> <td><div align="right">Group:</div></td> <td><div align="left"> <?php $size = sizeof($groups) - 1; echo "<select name=\"group\" id=\"group\">"; for($count = $size;$count > 0;$count--) { echo "<option value=\"$count\""; if($group == $count) { echo " selected"; } echo ">$groups[$count]</option>"; } ?> </div><div align="left"></div></td> <td>Flags: <?php echo "$flags";?></td> </tr> <tr> <td><div align="right">Immunity Level:</div></td> <td colspan="2"><div align="left"> <?php echo "$immune";?> </div></td> </tr> <tr> <td><div align="right"> </div></td> <td colspan="2"><div align="left"> <input name="admin_id" type="hidden" value="<?php echo "$id";?>" /> <input name="admin_id" type="hidden" value="<?php echo "$admin_id";?>" /> </div></td> </tr> <tr> <td> </td> <td colspan="2"><input type="submit" name="button" id="button" value="Submit"></td> </tr> </table> </form> And my update page is this.... <?php include 'config.php'; include 'access.php'; if(!isset($_SESSION['session_id'])) { die("You are not logged in and cannot view this page."); } $name = $_POST['name']; $group = $_POST['group']; $admin_id = $_POST['admin_id']; $db = mysql_connect ($hostname, $username, $password) or die ('Failed to connect to database: ' . mysql_error()); mysql_select_db($database); $query = "UPDATE $smadmin_table a INNER JOIN $smadmgrp_table b ON a.id = b.admin_id SET a.name = '" . mysql_real_escape_string($name) . "', b.group_id = '" . mysql_real_escape_string($group) . "' WHERE b.admin_id = '" . mysql_real_escape_string($admin_id) . "'"; mysql_query($query) or die("Query failed: " . mysql_error()); mysql_close($db); echo '<br /><br /><br /><center><font size=\"+4\" color=\"red\">Admin updated.</center></font>'; print_r($_POST); ?>
  4. that worked out beautifully! thanks so much!
  5. first of all thank you, i ran that query and got an error, " Unexpected symbol 'Group' " as for multiple groups for admins we wont be using more than 1 group per admin. if using outer joins is going to display bob as well then i dont want that ... i just want the admins to be displayed with the correct information
  6. Hello all, I have 4 tables that i need to join and pull matching data from, First let me describe the tables and then i can explain futher the issue i am having. The tables manage admins in an online game, and i am unable to change the table structure due to it being hardcoded into the game. Now for the tables, DB Name admmgr Table 1 (Holds all members of my clan weather they have admin or not) clan_members authid (primary key)(manually defined) name rank (number from 1 - 10) Table 2 (holds the actual admins) sm_admins id (primary key)(auto inc) authtype identity (same as authid in clan_mambers) password flags (usally NULL as we use the groups flags instead) name (same as name in clan_members so no need to call this field again) immunity (usally NULL as we use the groups Immunity) Table 3 (Holds the Groups that each person in sm_admins can be assigned to) sm_groups id (primary key)(auto inc) flags (the flags that we use to give admin permissions) name (name of the group) immunity_level Table 4 (Holds the information of which admin is assigned to which group) sm_admins_group admin_id (same as id in sm_admin) group_id (same as id in sm_groups) inherit_order what i am trying to do is display each member that is in clan_member that is in each group, thier flags, which group name they are in, thier authid and thier name example to follow clan_members= authid 123456, name john, rank leader authid 654321, name chris, rank member authid 987456, name bob, rank NULL sm_admins= id 1, authtype steam, identity 123456, password NULL, flags NULL, name John, immunity NULL id 2, authtype steam, identity, 654321, password NULL, flags NULL, name Chris, immunity NULL sm_groups= id 1, flags abcdefgh, name Leaders, immunity_level 10 id 2, flags gh, name Members, immunity_level 1 sm_admins_groups= admin_id 1, group_id 1, inherit_order 0 admin_id 2, group_id 2, inherit_order 0 the display i am looking for is this: Name AuthID Rank Group Flags Immunity John 123456 Leader Leaders abcdefgh 10 chris 654321 Member Members gh 1 Now i know i have to use left/right joins and i have done this before with 2 tables below is the code i used to do that and it works flawlessly, im just not sure how to edit the query to include 4 tables.... SELECT clan_members.authid, clan_members.rank, clan_members.name, admins.access FROM bioclan.clan_members LEFT OUTER JOIN bioclan.admins ON clan_members.name = admins.name WHERE clan_members.rank = 9 ORDER BY clan_members.rank DESC, clan_members.name Thank you in advance for your help!
  7. Firstly, thank you so much for the code, i will make sure to credit you in the code. also it works to show the textfield, however im not sure why but it is saving "--other--" in the db instead of the what i type the textfield. any ideas as to why? below is the code. The Form <tr> <td>Access Flags:</td> <td><select name='access' id='access' onchange="showOther(this, 'other_access');"> <option selected>Select Level</option> <option value='abcdefghijklmnopqrstu'>Leader/CoLeader</option> <option value='bcefijnprstu'>Tech</option> <option value='bcdefijmnopqrstu'>Upper Admin</option> <option value='bcefijnprstu'>Mid Admin</option> <option value='cfu'>Recruit Admin</option> <option value='u'>Member</option> <option value="--other--">--Other--</option> </select></td> </tr> <tr> <td><input type="text" name="other_access" id="other_access" style="visibility:hidden;"> </td> <td> </td> </tr> the processor <?php $auth = $_POST['auth']; $name = $row['name']; //$access = $_POST['access']; $access = ($_POST['access']=='--other--') ? $_POST['other_access'] : $_POST['access']; mysql_free_result($result); .........
  8. i have a form that updates a mysql table and i currently only have a dropdown that is hard coded with options, what i would like to do is have it to where if i choose "other" in the dropdown it will create a textfield and use that as the information being passed on to the form processor, i know this can be done with DOM just not sure how. any examples would be great Thanks a ton for all the help!
  9. ok i went back to the other code and managed to get that to work, Thank you both very much! i really wish there was some sort of karma system to where i could give you guys kudos. Mike i am sorry but i dont know enough about php to use the glob effectively, although the code worked it would only work if i was runing teh script from the directory it was searching for files. below is the code i got to work. <?php $dir = "./downloads/computer/"; $thelist=""; if ($handle = opendir('./downloads/computer')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir($dir.$file) === false) { $pieces = explode('.', $file); array_pop($pieces); //$file = implode('.', $pieces); $file_name = implode('.', $pieces); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file_name.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?>
  10. ok that is doing great, but it is not pulling the files from the specified folder only the files that are in the folder that the script is running from, how do i tell glob to look in a specific folder and keep it from displaying the link with the dir structue?
  11. mike you had it right the script isnt running in the folder with the files, so i will have to define the glob as =path/to/*.* the only issue i am having now is the way the link is displayed. see last post for update
  12. ok that made things a bit better, however the link is still being displayed as ./downloads/computer/filename the current code <?php $glob = glob("./downloads/misc/*.*"); $thelist = ""; foreach($glob as $file) { $pieces = explode('.', $file); array_pop($pieces); $filename = implode('.', $pieces); $thelist .= '<li><a href="'.$file.'">'.$filename.'</a></li>'; } echo $thelist; ?>
  13. ok that is almost working, just a few things the link is being generated with the path in front of the file name without the extension, and teh url is being generated without the extension so i am getting ./downloads/misc/Skyplayer and when clicked on it takes me to misc/filename instead of misc/filename.ext
  14. @mikesta707, i really wouldnt mind using blob, but even after looking at the site i for the life of me cant figure it out, if you could show me a working example of listing the files in a specific dir, and creating a link for each file and then displaying each lin inside of a <li></li> that would help me understand its functions as well as furthering me on my quest ...
  15. ok dlright.inc should be showing the hard coded links to Vent on the top and on bottom should only be showing the links to any files in the %siteurl%/downloads/misc then the dlleft.inc should be showing Top section ONLY any files in the %siteurl%/downloads/gaming dir bottom section ONLY any files in the %siteurl%/downloads/computers dir does that clear it up ?
  16. ok well ... that kinda work ... upon trying this code in the following manner it is listing all files in other subdirs as well... my page is proke up in 3 include files left mid and right i broke the downloads into different subdirs (gaming, computer, and misc) i put the code into the right.inc as we discussed and now i am seeing not only the files in the misc subdir of downloads but any file inside any subdir of the main .... also the links to teh files are not using the .extension i even tried to remove the extension strip code and that didnt work either. you can look at the link and see what i mean i know i havent explained very clear. link: http://biogamingservers.com/downloads.php Dir structure Site_Root Downloads Computers Gaming Misc download.php (located in site root) <!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=iso-8859-1" /> <title>.:BIO:. - Downloads</title> <link rel="stylesheet" type="text/css" href="style.css" /> <style type="text/css"> <!-- .style1 {color: #df6e22} .style2 {color: #FFFFFF} --> </style> </head> <body> <div id="container"> <div id="nav-container"><?php include("includes/nav.inc"); ?></div> <div id="left"> <?php include("includes/dlleft.inc"); ?> </div> <div id="middle"> <img src="images/main_banner.gif" alt="" /> <?php include("includes/dlmid.inc"); ?> </div> <div id="right"> <?php include("includes/dlright.inc"); ?> </div> <div id="footer"> RE-Coded by .:BIO:. Archangel</div> </div> </body> </html> dlleft.inc (located in site_root/includes) <h1>Gaming<span class="style1">Files</span></h1> <ul> <?php $dir = "./downloads/gaming/"; if ($handle = opendir('./downloads/gaming')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir($dir.$file) === false) { $pieces = explode('.', $file); array_pop($pieces); $file = implode('.', $pieces); $file_name = implode('.', $pieces); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file_name.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul> <h1>Daily<span class="style1">Screenie</span></h1> <div class="box-bg"><img src="../images/ct_affiliate.jpg" width="88" height="31" /></div> <h1>Computer<span class="style1">Files</span></h1> <ul> <?php $dir = "./downloads/computer/"; if ($handle = opendir('./downloads/computer')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir($dir.$file) === false) { $pieces = explode('.', $file); array_pop($pieces); $file = implode('.', $pieces); $file_name = implode('.', $pieces); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file_name.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul> dlright.inc (located same as dlleft.inc) <h1>Ventrilo<span class="style1">Clients<span class="style2">3.0.1</span></span></h1> <ul> <li><a href="./downloads/vent/ventrilo-3.0.5-Windows-i386.exe" target="_blank">Windows - 32bit</a></li> <li><a href="./downloads/vent/ventrilo-3.0.5-Windows-x64.exe" target="_blank">Windows - 64bit</a></li> <li><a href="./downloads/vent/ventrilo-3.0.4-Darwin-universal.pkg.zip" target="_blank">Mac OSX 10.3 or higher - 32bit</a></li> <li></li> <li></li> <li></li> <li></li> </ul> <h1>Other<span class="style1">Files</span></h1> <ul> <?php $dir = "./downloads/misc/"; if ($handle = opendir('./downloads/misc')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir($dir.$file) === false) { //$pieces = explode('.', $file); //array_pop($pieces); //$file = implode('.', $pieces); //$file_name = implode('.', $pieces); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul>
  17. YAY!!! that worked great! Thank you soooooooo much for all the help!~
  18. ok here is the code now with the latest changes, 3 things, A. if i use is_dir i still get the subdirs B. if i use is_file i get nothing C. if i uncomment the code to strip teh extension i get Array as the link although the link is pointed to the right file. UPDATE: ok with the extension taken off i lose the subdir listings, however i have a break in the list where the subdirs used to be. (the extensions are being removed.) Again thank you so much for all the help. i really appreciate this. Now if we can get rid of the extra line that the subdirs are creating would be great. you can see what i am talking about here http://biogamingservers.com/downloads.php <h1>Other<span class="style1">Files</span></h1> <ul> <?php $dir = "./downloads/"; if ($handle = opendir('./downloads')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir($file)===false) { $pieces = explode('.', $file);array_pop($pieces); $file = implode('.', $pieces); $file_name = implode('.', $pieces); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file_name.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul>
  19. ok i tried the following code and now it is not showing anything at all. did i mis use the is_file()? You may have to spoon feed this to me, i have never used PHP for files before. as for the extension removing it should look like this? <h1>Other<span class="style1">Files</span></h1> <ul> <?php $dir = "./downloads/"; if ($handle = opendir('./downloads')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_file($file)) { $pieces = explode('.', $file);array_pop($pieces); $file = implode('.', $pieces); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$pieces.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul> <h1>Other<span class="style1">Files</span></h1> <ul> <?php $dir = "./downloads/"; if ($handle = opendir('./downloads')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_file($file)) { $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul>
  20. Goldeneye, i tried that fix and it still shows the subdirs.
  21. how can i make this code not show subdirs? also (not as important) but i would like to strip teh extension from the filename in the link so when the link is displayed it will look like thisfile instead of thisfile.ext <?php $dir = "./downloads/"; if ($handle = opendir('./downloads')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file.'</a></li>'; } } closedir($handle); } ?> <?=$thelist?> </ul>
  22. yup that solved it THANKS!!!!! a ton (psst! i have no solved option)
  23. @play_ : firstly,thank you for your response. 1.Yes i checked to see if the query is yielding the results that i expect, and you can see in the array.jpg i have echoed the array info at the top, it is indeed passing the $name from the hidden field but it is the name of the last record in the db that its pulled from the db no matter which record i select. 2. I will attempt this, and the reason for the "" around the vars is because dreamweaver is foolish LOL and the same goes for the <div align="center"> aswell. @abazoskib: again, thank you for your resonse, and i will change that portion to check to see if the submit is being used you both have really helped me in this and i really appreaciate all of it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.