Jump to content


  • Posts

  • Joined

  • Last visited


About rondog

  • Birthday 06/05/1986

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    San Diego

rondog's Achievements

Advanced Member

Advanced Member (4/5)



  1. also the reason I am selecting from all those different tables is because the user can turn on and off what fields they want to display. Right now I just have the disk information checked, but I could potentially have say some memory fields checked
  2. Ok looking at this query is going to look scary. It is generated through a number of loops and what not. The issue I am running into is their wont always be a controller in the system, so if their happens to not be, the entire query fails if their is nothing in the system_controllers table that has a system_id of cam_systems.id. <?php $q = " SELECT cam_systems.id, cam_systems.cam_systems_warranty, GROUP_CONCAT(system_disks.system_disks_qty) AS system_disks_qty, GROUP_CONCAT(system_disks.system_disks_make) AS system_disks_make, GROUP_CONCAT(system_disks.system_disks_model_no) AS system_disks_model_no, GROUP_CONCAT(system_disks.system_disks_size) AS system_disks_size, GROUP_CONCAT(system_disks.system_disks_serial_no) AS system_disks_serial_no FROM cam_systems, system_controllers, system_cpus, system_disks, system_macip, system_memory, system_power WHERE cam_systems.location_id = '1' AND system_controllers.system_id = cam_systems.id AND system_cpus.system_id = cam_systems.id AND system_disks.system_id = cam_systems.id AND system_macip.system_id = cam_systems.id AND system_memory.system_id = cam_systems.id AND system_power.system_id = cam_systems.id GROUP BY cam_systems.id LIMIT 0,10"; ?> I dont even know where to start right now as to what I should do. Its almost like I need to do an if in that statement in order to add that 'AND system_controllers.system_id = cam_systems.id'
  3. Ah ok I gotcha..It is succeeding now. The field is set as varchar so no it isnt a number exactly. I guess its more of a "2" than a 2 if that makes sense. Well you are a life saver. That works beatifully. I had never used group_concat til now. That is very useful. The return value is a string obviously so if I want to display '4 x 1 TB, 2 x 800 GB', am I better off just using explode on the values?
  4. ok this is more like what I was thinking. I modified the query to match mine like you said, but the returned result is false so the query is failing. $sql = " SELECT GROUP_CONCAT(system_disk_qty AS CHAR) AS system_disk_qty, GROUP_CONCAT(system_disk_size AS CHAR) AS system_disk_size FROM system_disks WHERE system_id = 2 GROUP BY system_id"; $query = mysql_query($sql); if ($query) { echo "succeed"; } else { echo "failed"; } Any ideas?
  5. I've tried using your method and I am getting an "Uninitialized string offset"
  6. when I do a "SELECT * FROM system_disks WHERE system_id = 'aNumber'" and their is more than one result with that system_id, I get more than one result obviously. I essentially need two results in one row. I've took a screen shot of what it is doing and what I need it to do. The blurred row is a different system_id This is what the while ($row = mysql_fetch_array($query)) is currently doing: This is what I would like it to do: Sorry if this is a dumb question, I've been coding the past 48 hours and my brain is fried
  7. never mind, i am a retard...I didn't close my <br/> tag..
  8. Hey, another questions regarding this. Why does this for loop not work on the other array fields? //--> CONTROLLERS $system_controllers_qty = $_POST['system_controllers_qty']; $system_controllers_make = $_POST['system_controllers_make']; $system_controllers_model = $_POST['system_controllers_model']; $system_controllers_serial_no = $_POST['system_controllers_serial_no']; for ($i = 0; $i < count($system_controllers_qty); $i++) { echo "qty " . $system_controllers_qty[$i] . "<br/"; echo "make " . $system_controllers_make[$i] . "<br/"; echo "model " . $system_controllers_model[$i] . "<br/"; echo "serial_no " . $system_controllers_serial_no[$i] . "<br/"; } This only outputs the $system_controllers_qty, yet if i do a print_r on each, they all contain data. In theory, they will all contain data even if its an empty string.
  9. This looks like exactly what I need. Thanks for the ideas guys.
  10. Hey guys I have a form, but on the form you are able to add extra fields. My question is how would I POST those extra fields? The way I always do it is $_POST['field_name'], however how would I know if theyve added new fields. Here is an image of what the field looks like so you get a better idea of what im talking about.
  11. ok it is still not working :'( unlink("var/www/vhosts/aimanmotor.com/httpdocs/_ronnie/".$row['avatar']); $row['avatar'] will look something like this: profile/avatars/1248316474ronnies.jpg
  12. complete path like: http://mysite.com/profile/avatars/blah.jpg ? My upload path works fine..I dont get it.
  13. I have an avatar upload area. That works fine. I want to unlink the users old avatar and it doesn't seem to be doing it. I made sure the folder has 777 permissions so its not that. Here is my code: <?php //avatarupload.php include "connect.php"; $username = $_POST['username']; $file = $_FILES['Filedata']['tmp_name']; $info = getimagesize($file); if ($info[0] == 80 && $info[1] == 80) { //--- Delete the old avatar if its not the default $query = mysql_query("SELECT avatar FROM fd_users WHERE username = '$username'"); $row = mysql_fetch_array(); if ($row['avatar'] != "profile/avatars/default.jpg") { unlink("../".$row['avatar']); } //--- Add the new avatar $addTime = mktime(); $l_sFileName = strtolower( str_replace( " ", "_", basename( $_FILES['Filedata']['name'] ) ) ); $l_sFilePath = "../profile/avatars/".$addTime.$l_sFileName; $fname = "profile/avatars/".$addTime.$l_sFileName; move_uploaded_file( $file, $l_sFilePath ); $sql = mysql_query("UPDATE fd_users SET avatar = '$fname' WHERE username = '$username'"); echo $fname; } else { echo "Invalid file dimensions!"; } ?> The reason I do the ../ is because this file is in a dir called php. Up one level is profile/avatars/the users avatar.jpg
  14. Ok I pretty much did exactly what you posted. Its not the cleanest, but it works..any suggestions? if (isset($_POST['save'])) { $id = $_GET['id']; $current = mysql_query("SELECT * FROM users WHERE id = '".$id."'")or die(mysql_error()); $current = mysql_fetch_array($current); $salutation = $_POST['salutation']; $firstname = mysql_real_escape_string($_POST['firstname']); $lastname = mysql_real_escape_string($_POST['lastname']); $email = mysql_real_escape_string($_POST['email']); $userid = mysql_real_escape_string($_POST['userid']); $active = $_POST['actives']; $level = $_POST['level']; $updates = array(); $status = ""; if ($current['salutation'] != $salutation) { array_push($updates,"salutation = '".$salutation."'"); } if ($current['firstname'] != $firstname) { array_push($updates,"firstname = '".$firstname."'"); } if ($current['lastname'] != $lastname) { array_push($updates,"lastname = '".$lastname."'"); } if ($current['email'] != $email) { $query = mysql_query("SELECT email FROM users WHERE email = '".$email."' AND id != '".$id."'") or die(mysql_error()); $num = mysql_num_rows($query); if ($num > 0) { $status .= "The email you chose is already in use.<br/>"; } else { array_push($updates,"email = '".$email."'"); } } if ($current['userid'] != $userid) { $query = mysql_query("SELECT userid FROM users WHERE userid = '".$userid."' AND id != '".$id."'") or die(mysql_error()); $num = mysql_num_rows($query); if ($num > 0) { $status .= "The user ID you chose is already in use."; } else { array_push($updates,"userid = '".$userid."'"); } } if ($current['active'] != $active) { array_push($updates,"active = '".$active."'"); } if ($current['level'] != $level) { array_push($updates,"level = '".$level."'"); } if ($status == "" && count($updates) != 0) { $query = mysql_query("UPDATE users SET ".implode(", ",$updates)." WHERE id = '".$id."'") or die(mysql_error()); $status .= "Successfully updated."; } }
  • 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.