Jump to content

jammesz

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Everything posted by jammesz

  1. This should work: <html> <body> <table width="100%" align="center"> <tr><td><form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <?php $conn=odbc_connect('dsn','un','pw'); if (!$conn) {exit("Connection Failed: " . $conn);} //we've failed the connection $sql="SELECT * FROM divisional_office WHERE name='office1' OR name='office2' OR name='office3' ORDER BY name"; //your query string $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} // some SQL error echo "<select name='someoffice'>"; while (odbc_fetch_row($rs)) //iterates through each database row it's fetched { $officename=odbc_result($rs,"name"); //change to whatever you want, this will grab the results $LOC_CODE=odbc_result($rs,"LOC_CODE"); echo "<option value=\"".$LOC_CODE."\">$officename</option>"; } echo "</select> <input type=\"submit\" name=\"submit_office\" value=\"Select\"></form>"; echo "</td><td>"; if(isset($_POST['submit_office'])){ $sql="SELECT * FROM staff WHERE LOC_CODE='".$_POST['someoffice']."'"; //your query string $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} // some SQL error echo "<select name='somename'>"; while (odbc_fetch_row($rs)) //iterates through each database row it's fetched { $compname=odbc_result($rs,"first_name"); //change to whatever you want, this will grab the results $conname=odbc_result($rs,"last_name"); echo "<option>$compname $conname</option>"; } odbc_close($conn); echo "</select>"; } echo "</td></tr></table>"; ?> </body> </html> This is assuming that LOC_CODE is in both tables. If this doesnt work than ill need to know how the two tables are linked.
  2. No, there are four seperate fields in the db, one for each of the checkbox variables. If the field equals 1 then the user can access that area, if it equals zero they can't. And if all of them equal 0 then they shouldn't be activated, which again is a seperate field where 1 equals activated and 0 equals not. But i can take it from here, many thanks for all your help Your welcome. BTW, ignore the code that I sent in my previous post (the one containing 'I can now probably say that your only updating one field in the database.'). I made a big mistake in it lol.
  3. Yes it does. That method will work
  4. I don't know what your database structure is so i cant really help you specifically. In other words what your asking can be done many ways but it all depends on the database structure. So if you can post it on here than I won't have to type out all the different ways .
  5. try hard coding: if ($extension == "avi" OR $extension == "zip") // is extension ext or EXT ? echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />"; It should look like this: <?php $current_dir = "./"; //Put in second part, the directory - without a leading slash but with a trailing slash! $dir = opendir($current_dir); // Open the sucker echo ("<p><h1>List of available files:</h1></p><hr><br />"); while ($file = readdir($dir)) // while loop { $parts = explode(".", $file); // pull apart the name and dissect by period if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part $extension = end($parts); // set to we can see last file extension if ($extension == "avi" OR $extension == "zip"){ // is extension ext or EXT ? echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />"; // If so, echo it out else do nothing cos it's not what we want } } } echo "<hr><br />"; closedir($dir); // Close the directory after we are done ?> I've tested this on my server and it works fine. note: you need to change the $current_dir back to what you have
  6. My response before was just a basic guideline. This will work though: <?php if(isset($_POST['activate_submit'])){ foreach($_POST['userID'] as $uID){ echo $uID; echo "<br>"; $CPM = isset($_POST[$uID.'_CPM']) ? 'yes' : 'no'; echo $CPM; echo "<br>"; $CPMH = isset($_POST[$uID.'_CPMH']) ? 'yes' : 'no'; echo $CPMH; echo "<br>"; $CM = isset($_POST[$uID.'_CM']) ? 'yes' : 'no'; echo $CM; echo "<br>"; $CJ = isset($_POST[$uID.'_CJ']) ? 'yes' : 'no'; echo $CJ; echo "<br>"; // other code or mysql query (update/insert) } exit; } ?>
  7. I have modified your given code to do what you ask via the form method. This will work assuming you have a office field in your staff table. I dont know what the office field name is so i've put it as 'officename', so you should change it to what ever the fields actual name is. <html> <body> <table width="100%" align="center"> <tr><td><form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <?php $conn=odbc_connect('dsn','un','pw'); if (!$conn) {exit("Connection Failed: " . $conn);} //we've failed the connection $sql="SELECT * FROM divisional_office WHERE name='office1' OR name='office2' OR name='office3' ORDER BY name"; //your query string $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} // some SQL error echo "<select name='someoffice'>"; while (odbc_fetch_row($rs)) //iterates through each database row it's fetched { $officename=odbc_result($rs,"name"); //change to whatever you want, this will grab the results echo "<option value=\"".$officename."\">$officename</option>"; } echo "</select> <input type=\"submit\" name=\"submit_office\" value=\"Select\"></form>"; echo "</td><td>"; if(isset($_POST['submit_office'])){ $sql="SELECT * FROM staff WHERE officename='".$_POST['someoffice']."'"; //your query string $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} // some SQL error echo "<select name='somename'>"; while (odbc_fetch_row($rs)) //iterates through each database row it's fetched { $compname=odbc_result($rs,"first_name"); //change to whatever you want, this will grab the results $conname=odbc_result($rs,"last_name"); echo "<option>$compname $conname</option>"; } odbc_close($conn); echo "</select>"; } echo "</td></tr></table>"; ?> </body> </html> hope this helps
  8. You will need to integrate a form or AJAX (preferred) to update the second drop down box with the relevant results
  9. Notepad is ok but I would personally recommend notepad++ for editing on windows. You should try it
  10. the fact that it says generator Msftedit 5.41.15.1515 suggests that its your editors fault for this happening. What editor are you using?
  11. Something along these lines should work: one.php <form action="two.php" method="POST"> <?php $q=mysql_query("SELECT * users WHERE activated=0"); while($r=mysql_fetch_array($q)){ ?> <?=$r['username']?><br /> <input type="hidden" name="userID[]" value="<?=$r['id']?>"> Access area one: <input type="checkbox" name="<?=$r['id']?>_A1"><br /> Access area two: <input type="checkbox" name="<?=$r['id']?>_A2"><br /> Access area three: <input type="checkbox" name="<?=$r['id']?>_A3"><br /> Access area four: <input type="checkbox" name="<?=$r['id']?>_A4"> <hr> <?php } ?> <input type="submit" name="activate_submit" value="submit"> </form> two.php <?php if(isset($_POST['activate_submit'])){ foreach($_POST['userID'] as $uID){ $a1=$_POST[$uID.'_A1']; $a2=$_POST[$uID.'_A2']; $a3=$_POST[$uID.'_A3']; $a4=$_POST[$uID.'_A4']; // other code or mysql query (update/insert) } } ?>
  12. this possibly might be your editors fault. Post the 'page source' code that your browser generates.
  13. $sql = "SELECT * FROM Employees WHERE id=$id"; should be $sql = "SELECT * FROM Employees WHERE ID=$id"; from what i can gather from this line $ID=$r["ID"];
  14. Can you please explain more clearly what you want to do? I can make a guess that you want to make the submit button disable and enable when something happens? In that case you can use this to do that: document.getElementById("submitButtonID").disabled=true; and document.getElementById("submitButtonID").disabled=false;
  15. your location $location = basename( $_FILES['file']['name']); isn't a proper location (its just a filename). it should at least have './' or '/' before basename( $_FILES['file']['name']). Also check your file permissions etc. Im not really sure what the problem is but just hoping this may help.
  16. i am pretty sure that you need to use move_uploaded_file() function before using the uploaded file to convert to png
  17. if you still cant get it to work you should post your code here
  18. Theres a typo in your php. Before: <input type="hidden" name="question" value="'.$question'"> //i want the ..... After: <input type="hidden" name="question" value="'.$question.'"> //i want the ..... Insert a dot after $question
  19. Your welcome, glad i can help. Remember to mark this topic as solved too.
  20. Not sure if i understand your problem correctly or not, but you can modify this snippet to fix it. BTW this example has 100 images. <?php // example image array (100 images) $image_array=array(); for($i=1;$i<101;$i++){ $image_array[]=$i; } // end $count=0; foreach($image_array as $image){ $count++; if($count == 1){ echo '<ul>'; } echo '<li>'.$image.'</li>'; if($count==12){ $count=0; echo '</ul>'; } } if($count !== 0){ $diff=12-$count; for($i=1;$i<$diff+1;$i++){ echo '<li>Blank '.$i.'</li>'; } echo '</ul>'; } ?> It fills in the shortage of images with 'blank' to make up 12 items in a list. The result of the last ul is this: * 97 * 98 * 99 * 100 * Blank 1 * Blank 2 * Blank 3 * Blank 4 * Blank 5 * Blank 6 * Blank 7 * Blank 8 hope this helps
  21. Why not combine the two php pages by having the html popup in index.php and getting index.php to handle the login?
  22. Hi, I was wondering if there is a solution to keeping a scrollbars position in a div, after Ajax updates a parent div containing that div. Every time Ajax updates the parent div the scrollbar goes back to the top. example: <div id="Parent div"> info and other stuff <div id="Scrollbar div">User list</div> </div> Just to be clear... Ajax updates (empties and inserts new html) the Parent div and the Scrollbar div is included in that update, in which the Scrollbar divs scrollbar goes to the top automatically. I know that I can solve this problem by making two Ajax calls and separating the two divs but I really want to stick with the one Ajax call to reduce the load. Any help would be appreciated, thanks
  23. I ended up doing: sudo -u james firefox Where apache is set to run as user james and ran the php script while logged into the same account. This solved my problem but not the way i prefered. Ill mark this thread as solved anyway.
  24. Just an update.... I've edited /ect/gdm/gdm.conf and set disallowTCP=true to false and restarted my comp and i now get this error in the apache log: (firefox:11592): GnomeUI-WARNING **: While connecting to session manager: Could not open network socket.
  25. Hi im running ubuntu jaunty with lamp setup. Basically i want to be able to use php's exec() function to open firefox (so i can get my ubuntu comp to play youtube videos after commanding it to from my mobile connected to the comps intranet). this is what i've done so far: * tried exec("firefox") and apache logs say no display set. * tried exec("firefox --display=:0"); added all my comps ip addresses, localhost and :local to xhost and apache logs say Error: cannot open display: :0 * set apache to use my username to run in httpd.conf and apache log says (firefox:7390): GnomeUI-WARNING **: While connecting to session manager: None of the authentication protocols specified are supported. Btw running xauth list tells me that my display is :0 Any ideas on how to fix this? I've searched long and hard to find a solution and only came up with bits and pieces that get me to where i am now with this.
×
×
  • 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.