Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

claro's Achievements


Member (2/5)



  1. seems like that is the answer. thank you !
  2. I haven't thought of that. It doesn't display any error so I thought it's okay. What do you mean by overwriting objects? thank you for the response.
  3. Greetings! I'm practicing oop. I have a problem in declaring classes in loop. public function save($sn,$year,$type) { Connection::conn(); try{ $sql = " SELECT * FROM device.sn WHERE sn_number = :sn AND sn_delstat IS NULL"; $q = connection::$db->prepare($sql); $q->bindParam(':sn', $sn,PDO::PARAM_STR); $q->execute(); $count = $q->rowCount(); if ($count ==0) { $sql = "INSERT INTO device.sn (dname_id,sn_year,sn_number) VALUES (:dname,:year,:snumber)" ; $q = connection::$db->prepare($sql); $q->bindParam(':snumber', $sn); $q->bindParam(':year', $year); $q->bindParam(':dname', $type); $q ->execute(); $count = $q->rowCount(); if ($count>0) { echo "<div class='space'></div>"; echo '<div class ="success">Successfully added'.'</div>'; } else { echo '<div class ="error">Error in adding.</div>'; } } else { echo '<div class ="error">'.$sn.'already exist.</div>'; } }catch (Exception $e){ print "Error!: ". $e->getMessage(); } } and I call my class this way foreach ($val as $sn) { if (!empty($sn)) { $dev = new Sn(); $dev-> save($sn,$year,$device); } else { echo 'sn requied'; } } My code is all working, my problem is to display them properly, like when I save 2 items, there are two '<div class ="success">Successfully added'.'</div> is displayed. How can I make it display in a single div including the errors. Any help will do. Thank you.
  4. I have here two arrays. Array1 has a related value to array2. What I need is that I'm going to save both values at once. I've used 'array_combine' function but my arrays are having unequal keys. Any help is greatly appreciated. Thank you. $type = $_POST['dev_type']; $sn = $_POST['dev_sn']; Array ( [0] => 22 [1] => 19 [2] => 66 [3] => 62 [4] => 64 ) Array ( [0] => sn1 [1] => sn2 [2] => sn3 )
  5. Ok. thank you for pointing that out. I'll try my best to explain it further. I have this page called lab_list.php <li><a href='home.php?mountlab=viewLab' target = _top>Laboratories</a></li> <li><a href='home.php?mountlab=setLab' target = _top>Mount Lab</a></li> and it will go to my home.php if(isset($_GET['action']) ) { $test = $_SERVER['DOCUMENT_ROOT'].'/devices/device_coffin'; } else if (isset($_GET['mountlab'])) { $test = $_SERVER['DOCUMENT_ROOT'].'/lab/lab_coffin'; } else { $test = $_SERVER['DOCUMENT_ROOT'].'/welcome'; } and pass me in lab_coffin.php. In this page, I have to columns, the sidebar and its content. What ever option in my sidebar, it's action will display in the content. if (($_GET['mountlab']) == "setLab") { $test = $_SERVER['DOCUMENT_ROOT'].'/lab/set/lab_add.php'; }else if (($_GET['mountlab']) == "setLabAct") { $test = $_SERVER['DOCUMENT_ROOT'].'/lab/set/lab_addaction.php'; }else if (($_GET['mountlab']) == "setLabact2") { $test = $_SERVER['DOCUMENT_ROOT'].'/lab/set/data_select.php'; } So when I clicked the mount lab in my list, it will pass me a page where I can select another options. In this page there is a transaction where I'm using jquery ajax..I tried it in a single page and it went well. Now when I try to integrate with my dynamic content, I'm lost.
  6. How can I rewrite my code below if my 'data_select.php' is in a variable $data = dataselect, that when it is set to true the data_select.php will show. I'm making a dynamic content in php and I'm not familiar with jquery. Any idea? thank you in advance. <script type="text/javascript"> $(document).ready(function() { $('a').click(function(){ $.get('data_select.php', {'page':$(this).text()}, function(data){ $('#content').html(data); }); }); }); </script> When I try firebug, the error says 'data_select.php' not found.
  7. What will this code do? I'm lost . Thank you
  8. Ok, hope this will make my self clear. Optimized-1.bmp 1. On this part the user will select the name of laboratory as well as the number of pc that will mount. Optimized-2.bmp 2. On this part, The laboratory name is displayed as well as the total number of pc. Also the generated pc list on the right. When the user click any on the list, the computer parts will appear on the right ( which is a form to be fill in), but as of now I start to get the list ID. Optimized-3.bmp 3. This part is my problem. The name of laboratory, and number of pc is gone. But I got the list Id. I am thinking that ajax or jquery can help me out on this problem. Any advice? Optimized-1.bmp Optimized-2.bmp Optimized-3.bmp
  9. I'm in dead end now I think, I must convince myself just to meet my needs. As long as I can avoid AJAX and js, I will. But I think this time is different now. Yes, I must get the value of my href attributes via ajax. I tried pure js but my page refresh after clicking the link, and my php values are affected.
  10. Ok I have a work around in my mind now. How about ajax call in getting id value in href? any idea? <li><a href="?page=page&id=<?php echo $val;?> " id="link1">Menu item</a></li>
  11. Thank you very much for that. I'm still confuse how to make this work. Selecting options from the left the action in the right.
  12. Not really a fan of ajax, since it is javascript. I don't want my project be dependent by it in terms of functionality. But, if it's the only way then I should convince myself to use it. Now I'm looking for simple script to work around. Thanks for the response. Enlighten me more about my project.
  13. Greetings!I think I'm on the most bloody part of my project, I have no idea how to work it out. I'm not good in explaining that's why I attached my illustration to show what my problem really is. I'm looking for frame-like effects in php for dynamic content. Like when I hit option from the left div ,action will display in right div. I'm in a computer laboratory inventory. Thank you in advance. the illustration has two blocks, my problem is in the right. Really need your advice.
  14. I think I found the error now. But I don't know how did it happen. array(3) { [0]=> array(2) { [0]=> string(10) "HDD " [1]=> string( "Harddisk" } [1]=> array(2) { [0]=> string(6) "MBOARD" [1]=> string(11) "Motherboard" } [2]=> array(2) { [0]=> string(10) "MTOR " [1]=> string(7) "Monitor" } } The string count of my 'HDD' and 'MTOR'.
  • 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.