Jump to content

Nodral

Members
  • Posts

    397
  • Joined

  • Last visited

Everything posted by Nodral

  1. but the initial query would be something along the lines of, SELECT product, manufacturer FROM tablea WHERE............ Then you say to run SELECT from tableb WHERE manufacturer = $tablea_manuf for each time you need the manufacturer profile details. Why not just do SELECT a.product, b.profile FROM tablea a JOIN tableb b ON a.manufacturer = b.manufacturer WHERE................. One hit to the DB instead of multiple. If you were pulling 5000 products in the first query you would need 5001 queries to your DB using some sort of looping system. With a JOINed query, you would only need 1 query which could return all the info into an array for display. Thus greatly reducing server load.
  2. but why do 2 single queries when one will pull the information from both tables in one hit, rather than get the product in one query, then the manufacturer in another?
  3. You could theoretically do this by changing your SQL query when you validate your user id against the user / password table. However you have a massive security risk if your master password falls into the wrong hands <?php if ($password == "MASTER PASSWORD") { $select="SELECT * (or however you have it set up) FROM user WHERE username ='$username'"; }else{ $select="SELECT * (or however you have it set up) FROM user WHERE username ='$username' AND password = '$password'"; }
  4. Hi All Just a shot in the dark here. I use Moodle 1.9 and have built several custom applicationts in it. However my latest one needs to be able to send automated emails out. Does anyone know where I can find the functions/classes etc to do this within the file structure? Cheers in advance
  5. Hi All This may fall into regex, so my apologies if it does. I have a string from a prebuilt database, where it details the information responses to a radio button input. The issue I have, is that it is in the format "d>>>>>>North East|North West|South East|South West" I can't guarentee the first character is always a d and I don't know how many '>'s there are. Can someone help me remove these, then I can populate into an array using explode().
  6. Nodral

    openid

    Hang on while I check my crystal ball!!! Any chance of some pointers on this? Code? Errors?
  7. Using a while loop is ok, except if the processing speed is incredibly slow for some reason, $i will hit 1000 and the loop will stop without the procedure completing. The correct way to do this is with a recursive function which will go forever until the conditions are met. As I said earlier, the problem sounds as though it s with the code in the script, not the functionality of using a recursive function. Until ankur0101 posts some code and/or errors we're all using guesswork as to how to help him.
  8. Have you got error_reporting switched on? Nobody will be able to help you much more unless we can see your code and an error
  9. The loop will go forever until the if condition is satisfied. You may have an issue with your if statement. Post your function code and we'll have a look see
  10. What you do is use Javascript to check the completed fields on the form with basic validation using onBlur (completed/incomplete, numbers, email format etc). Once these criteria are all satisfied, you then pass all the form values back to the server to check against your DB using PHP. Javascript / client side should not be used for referencing against a DB, just for checking the basics as to whether the form fields are filled in correctly. You need to write some code to connect to your DB in PHP and check the values from the form (sent back using POST method) and then produce a success / fail output to be sent back to the browser. There are loads of good tutorials around this, just use google to find them. Once again, use Javascript to validate the FORMAT of the input, and use PHP to validate against your DB. A hint for the future though, make sure you "clean" the user inputs prior to doing any sort of DB work to prevent SQL injection etc
  11. You can do this, but as PHP acts on the server and not the browser, you would need to return the form to the server to check the validation after every onBlur event. Javascript is the best to use for form validation prior to sending to the server for a final more thorough check.
  12. Why do you not want to create a function? You're going to be performing the same routine possibly hundreds of times depending on your processing speed. This is one of the main reasons for using functions. You could (theoretically) nest hundreds of If/else statements to acheive the same thing, but why bother when you can reuse the same code you write once?
  13. I'm no expert on this, but a recursive function would do the task you need. ie function conditionCHK(){ if (example.zip > 33 ){ $result= "done"; } else { sleep(15); conditionCHK(); } return $result; } As I said, I'm no expert so you will need to check the syntax and maybe read up on recursive function, but I's say this is probably your best bet.
  14. Hi This line , will not post anything as $result is a mysql data result. What code do you have in /new/newrotastaffprocess.php? How do you know it's not posting anything?
  15. Not sure about the ajax or javascript, but i'd have the value of the option as an id for the person you are selecting from the drop down box, then when you resubmit the page, run a query against your DB using this reference and this will give you the details you need. ie. to create dropdown $result.="<select name='people'><option value='%'>Select</option>"; $sql="SELECT id, forename, surname FROM people ORDER by surname"; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)){ $result.="<option value='".$row['id']."'>".$row['forename']." ".$row['surname']."</option>"; } $result .="</select>"; then $sql="SELECT forename, surname FROM employees WHERE id = $_POST['people']"; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)){ $result=$row['forename']." ".$row['surname']; }
  16. There are several other tables and columnswhch reference each other which I have omitted for the purpose of this query, and the DB contains several hundred thousand records so a restructure is out of the question. The query you have written will only return values where an employee of the location has attended a course which is not the given one, rather than ALL employees for a certain location which have not attended the course. I have some employees who have not attended any courses which would not show in your query. This is the same issue I am having.
  17. What code do you have at the moment? Are you getting any errors? Are you just wanting someone to write this for you, and if so you may want to post in the frelancing section.
  18. Morning All I'm having issues with a query I need to write. I have the following 2 tables 1 - id, employee number, employee name, location. 2 - id, employee number, course title I need to create a query where I can give the location and a course title and the values returned will be all those from the location who have NOT attended the course given. Any thoughts?
  19. You can do this with your SELECT statement (not shown in your code posted) Add a clause to the the end of the SELECT statement which is Then simply have $filter set as a column name by a $_POST from the form.
  20. Not sure if this is deliberate, but on line Your opening and closing quotes are different.
  21. Hi all Been trying to get my head around formatting a string, and struggling. I have a serious of numbers held in a DB and I need these to display as 5 figure numbers. if the DB held the record "48" I would need this to be displayed as "00048". Can anyone give me a clue. I've tried reading the php manual but this just confuses me more.
  22. Hi all I know this contains a bit of JavaScript but it comes from some dynamically created pages using php which are causing it an issue. Here's my scenario. I have a DB with locations, regions, jobtitles and names in it. My users can select from the DB a specific job title or a location. This can produce a report of information from a couple of people, up to over 100 (who can still be filtered by any of the above DB columns) I want to dynamically produce some JS buttons to show / hide any sections which are irrelevant to the user. eg I select by job title, it gives me all the managers, duty managers, staff, cleaners, etc from the DB for all locations. I then want 5 buttons to be on the page, each with a different region on it. (this I can do) I can dynamically label the divs around each of the user information. The issue I have is making the buttons do what I want. So if you press a button labelled "North West" it hides all records which are not from northwest region. Here's what I have so far, I just can't seem to get the functionality right as I know very little about JS. <script language=javascript type='text/javascript'> function showdiv(pass) { var divs = document.getElementsByTagName('div'); for(i=0;i<divs.length;i++){ if(divs[i].id.match(pass)){//if they are 'see' divs if (document.getElementById) // DOM3 = IE5, NS6 divs[i].style.visibility="visible";// show/hide else if (document.layers) // Netscape 4 document.layers[divs[i]].display = 'visible'; else // IE 4 document.all.divs[i].visibility = 'visible'; } else { if (document.getElementById) divs[i].style.visibility="hidden"; else if (document.layers) // Netscape 4 document.divs[i].visibility = 'hidden'; else // IE 4 document.all.divs[i].visibility = 'hidden'; } } } </script> and then one my php has processed I get a record such as. <div id='NEREGION'> <table border='1' > <tr><td colspan='4'>Glasgow </td></tr> <tr><td colspan='2' >Employee Name : **********</td><td >Employee Number : *****</td><td colspan='2'>Start Date 25th November 2002</td></tr> <tr><td colspan='3'> </td><td rowspan='3'><img src='image.php?ed=2063&y2007=1&y2008=1&y2009=0&y2010=0&y2011=0&forename=1234&surname=5436' height ='400px' width='350px'></td></tr><tr><td colspan='2'>20th June 2007</td><td> NFR Petrol Delivery - Refresher Course</td></tr><tr><td colspan='2'>2nd December 2008</td><td> Incremental Sales</td></tr></table></div> Any ideas?
  23. Hi Provided this is set up correctly within an HTML form, You would simply reference the return from the dropdown by using $sql="SELECT item WHERE price = ".$_POST['lowest']; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)){ $results[]=$row['item']; } You now have an array of all the items.
×
×
  • 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.