Jump to content

arimakidd

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Everything posted by arimakidd

  1. Quick question before I answer, the third table, "c_anwser_id" and "e_answer_id", I am assuming they are numbers. Are they the same? Have a relationship? I am trying to work out a "where" clause that would pull out the info. This third table, is it that each tableID represents an instance where the answers for employer and candidate are similar? In addition You description of the tables employer and candidate is not entirely clear. How many columns are there? You said in a situation where there are 9 answers the tables look like...ANSWER1,ANSWER2,ANSWER3....ANSWER9...... Now I would hate to think that your columns keep growing with answers! I am hoping you have one column for answer in each table for employer and candidate. Describe for me the columns only, not how many rows you have. If your table is set up the way I hope it is then you will execute a query
  2. In total (email info and email content) you have 22 variables I think. Not sure how many you need to validate but just use a for loop to iterate each element and perform whatever validation you need. First of course you need to put all your variables that require validation into a numerically indexed array. Then use the for loop to iterate through each item and perform whatever validation you require. The array would look something like this: $array = array("$to", "$subject", "$from" ....etc) Then use a for loop. The second expression which is evaluated should test against the number of items to be checked. So for example, if you have 5 items to validate then your for loop should look something like this: $item = 5; for($i =0; $i<=$item;$i++) { $array[$i]; //this is how to retrieve the item to be checked in the array. //perform validation here. } That should solve most if not all of your problems. Hope this helped.
  3. Sounds like you have alot of work to do. I would start by creating another table that would link the answers of both employer and candidate. With respect to you second part, that shouldn't be much of a problem as you can use $_POST variable to get the value of any form element. If you have to loop through multiple form elements then you use JavaScript to pull out element:value pairs and then use php to do the rest of processing. Sorry for being so vague but I am not entirely sure of the scope of your problem. No doubt though, php can solve anything. Add mysql to that or some db, then you are just fine.
  4. go to the following link to test your site and get an idea how well the google bot will award it points, http://tools.summitmedia.co.uk/spider/ In addition tools such as ibusinesspromoter is very useful. Link is http://www.ibusinesspromoter.com/. I use this tool often and it works. Last but not least you can load your site for free in free website submission sites, including google, here is a list: http://www.google.com/addurl/ http://www.submitexpress.com/submit.html http://www.freewebsubmission.com/ Hope this helped
  5. I am a bit unclear as to the situation. You data is coming from a database or a form? If a form, then you have to loop through the elements and with each iteration run a "if" statement to see of the check box was checked and then store that value in an array. When the looping is done you have an array of all the names or emails as you say. You can even run a loop and create an array where the index or key is the name and the value is the email address. If your data is coming from a database then what ever query you are running you can then put it in an array and use the 'foreach' function. The statement: foreach($pieces as $value) { } Will iterate through the entire array. In other words, foreach is a loop and on each round or turn or iteration the value of the present index will be assigned to the variable "$value". So when this is run all the values of the array in the array variable "$pieces" will be assigned to $value. In more detail lets say you have an array with 3 items, the first letters of the alphabet and the array is assigned to the variable $alpha, like this: $alpha = array("a","b","c"); And you use the foreach on it like this: foreach($alpha as $value) { echo $value."<br>"; } Your output would be: a b c Hope this helps somewhat.
  6. Another way to do this based on how you have described the tables would be to use arrays. Here would be the perfect case for a 2 dimensional array. The key or identifier for each answer in the candidate table would be the respective employer answer(or is that a normal array). Thus you would have index:value pairs being represented by (employee_answer:candidate_answer). You would have to write a function to build this array though which would be easy. You can then store this array and massage the data however like. If you want more detail, let me know I would be glad to help. If this is not the direction you want to go, then you can use a sql statement. However I don't have enough detail on the relationship of the tables. I would use join as a last resort as it is memory intensive. Is there a relationship between the tables? ID for employer is the same as candidate for example? If a relationship between any of the columns exist ie. one to one, one to many then you have alot of options with respect to using sql.
  7. I have been using phpmyadmin 2.8.2.4 for a long time but never used authentication with it. I have always used 'config' for the $cfg['Servers'][$i]['auth_type'] field. I would like to use authentication and so now have to change this field to 'http' from 'config' and remove the password. When i restart apache the login prompt comes up but when I enter the credentials nothing happens. The login prompt just keeps coming up. What to do?
  8. I thank you for the very swift response and something similar I did do and it has solved the problem of the "undefined" variable. Having said that lets get straight into it. Remember, for now I am interested in what works, I'll go back and clean up according to rules etc once it runs. Here is the new code for usage.php //Include the PS_Pagination class include('ps_pagination.php'); if(!isset($_GET["q"])) { $q = $_GET["q"]; } else { $q=$_GET["q"]; } //Connect to mysql db $conn = mysql_connect('localhost','root','newman$'); mysql_select_db('apis_live',$conn); $sql = "SELECT TRAVELLER_PKEY, FIRSTNAME, LASTNAME, MIDDLENAME FROM traveller WHERE FIRSTNAME like '".$q."%' OR LASTNAME like '".$q."%' OR MIDDLENAME like '".$q."%'"; I did not paste the entire thing just the part that changes. Everything else is the same. I also had to change ps_pagination.php. In order for the new code to work with $q I had to include it in the url of the "next" page links. Thus the adjustments are as follows: function renderLast($tag='Last') { if($this->page == $this->max_pages) { return $tag; } else { return '<a href="'.$this->php_self.'?page='.$this->max_pages.'&q='.$_GET["q"].'">'.$tag.'</a>'; } } /** * Display the next link * * @access public * @param string $tag Text string to be displayed as the link. Defaults to '>>' * @return string */ function renderNext($tag=' >>') { if($this->page < $this->max_pages) { return '<a href="'.$this->php_self.'?page='.($this->page+1).'&q='.$_GET["q"].'">'.$tag.'</a>'; } else { return $tag; } } /** * Display the previous link * * @access public * @param string $tag Text string to be displayed as the link. Defaults to '<<' * @return string */ function renderPrev($tag='<<') { if($this->page > 1) { return '<a href="'.$this->php_self.'?page='.($this->page-1).'&q='.$_GET["q"].'">'.$tag.'</a>'; } else { return $tag; } } /** * Display the page links * * @access public * @return string */ function renderNav() { for($i=1;$i<=$this->max_pages;$i+=$this->links_per_page) { if($this->page >= $i) { $start = $i; } } if($this->max_pages > $this->links_per_page) { $end = $start+$this->links_per_page; if($end > $this->max_pages) $end = $this->max_pages+1; } else { $end = $this->max_pages; } $links = ''; for( $i=$start ; $i<$end ; $i++) { if($i == $this->page) { $links .= " $i "; } else { $links .= ' <a href="'.$this->php_self.'?page='.$i.'&q='.$_GET["q"].'">'.$i.'</a> '; } } return $links; } /** * Display full pagination navigation * * @access public * @return string */ function renderFullNav() { return $this->renderFirst().' '.$this->renderPrev().' '.$this->renderNav().' '.$this->renderNext().' '.$this->renderLast(); } /** * Set debug mode * * @access public * @param bool $debug Set to TRUE to enable debug messages * @return void */ function setDebug($debug) { $this->debug = $debug; } } Notice the $_GET["q"] that is now in the links. So just ONE more problem to solve. Those said links when clicked, instead of keeping me on traveller.php I go to usage.php. Even though the very first result show properly in traveller.php, the moment I try to veiw any other page I go to usage.php and so the data is correct but I lost all my markup and fancy layout. I may drop the ajax all together and just use a simple form and use a "get" method. This app is strictly internal so security is not that big an issue. Sill would like a solution with the Ajax, not giving up just yet. I appreciate the response.
  9. I am using both an ajax live search and pagination. The ajax part works fine but due to unwieldy data, the live search started crashing browsers or just took to long to load. Thus I needed to paginate. This is where the problems started to occur. I attached all the files just in case anyone wanted to take a closer look at it. Okay, so lets start with the problem. When I try to paginate the very first page comes up fine. However when I click the link to go to the next page, the results are incorrect and spurious, not to mention the variable that holds the form GET info get lost and an undefined variable error occurs and last but not least I want the user to remain on traveller.php and not go to usage.php. The links send you to usage.php page. This is the code for the page where the live search is done. The name of this page is traveller.php <html> <head> <title>Testing</title> <script src="traveller.js"></script> </head> <body> <form> <input type="text" id="users" size="30" onkeyup="showResult(this.value)"> </form> <p> <div id="livesearch"> </div> </body> </html> You would notice that the ajax runs in a separate file called traveller.js. Here is the code // JavaScript Document var xmlHttp function showResult(str) { if (str.length==0) { document.getElementById("livesearch"). innerHTML=""; document.getElementById("livesearch"). style.border="0px"; return } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } [color=red]var url="usage.php"[/color] url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("livesearch"). innerHTML=xmlHttp.responseText; document.getElementById("livesearch"). style.border="1px solid #A5ACB2"; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } The only part in this file that needs editing, I have highlighted. var url="usage.php". ???You have to insert the name of the php paage that's processing the MySQL data and returning the results. Now for the page that does some of the processing. Its called usage.php //Include the PS_Pagination class include('ps_pagination.php'); $q = $_GET["q"]; //Connect to mysql db $conn = mysql_connect('localhost','username','password'); mysql_select_db('apis_live',$conn); $sql = "SELECT TRAVELLER_PKEY, FIRSTNAME, LASTNAME, MIDDLENAME FROM traveller WHERE FIRSTNAME like '".$q."%' OR LASTNAME like '".$q."%' OR MIDDLENAME like '".$q."%'"; //Create a PS_Pagination object $pager = new PS_Pagination($conn,$sql,20,20); //The paginate() function returns a mysql result set $rs = $pager->paginate(); echo "<table border='1'> <tr> <th>Details</th> <th>First Name</th> <th>Middle Name</th> <th>Last Name</th> </tr>"; while($row = mysql_fetch_assoc($rs)) { echo "<tr>"; echo "<td><a href='traveller-details.php?id=" .$row['TRAVELLER_PKEY']."'>Details</a></td>"; echo "<td>" . $row['FIRSTNAME'] . "</td>"; echo "<td>" . $row['MIDDLENAME'] . " </td>"; echo "<td>" . $row['LASTNAME'] . "</td>"; echo "</tr>"; } echo "</table>"; //Display the full navigation in one go echo $pager->renderFullNav(); As you can see this page refers to another page that creates all the objects. That page is called ps_pagination, and here is the code: class PS_Pagination { var $php_self; var $rows_per_page; //Number of records to display per page var $total_rows; //Total number of rows returned by the query var $links_per_page; //Number of links to display per page var $sql; var $debug = false; var $conn; var $page; var $max_pages; var $offset; /** * Constructor * * @param resource $connection Mysql connection link * @param string $sql SQL query to paginate. Example : SELECT * FROM users * @param integer $rows_per_page Number of records to display per page. Defaults to 10 * @param integer $links_per_page Number of links to display per page. Defaults to 5 */ function PS_Pagination($connection, $sql, $q, $rows_per_page = 20, $links_per_page = 10) { $this->conn = $connection; $this->sql = $sql; $this->rows_per_page = $rows_per_page; $this->links_per_page = $links_per_page; $this->php_self = htmlspecialchars($_SERVER['PHP_SELF']); if(isset($_GET['page'])) { $this->page = intval($_GET['page']); } } /** * Executes the SQL query and initializes internal variables * * @access public * @return resource */ function paginate() { if(!$this->conn) { if($this->debug) echo "MySQL connection missing<br />"; return false; } $all_rs = @mysql_query($this->sql); if(!$all_rs) { if($this->debug) echo "SQL query failed. Check your query.<br />"; return false; } $this->total_rows = mysql_num_rows($all_rs); @mysql_close($all_rs); $this->max_pages = ceil($this->total_rows/$this->rows_per_page); //Check the page value just in case someone is trying to input an aribitrary value if($this->page > $this->max_pages || $this->page <= 0) { $this->page = 1; } //Calculate Offset $this->offset = $this->rows_per_page * ($this->page-1); //Fetch the required result set $rs = @mysql_query($this->sql." LIMIT {$this->offset}, {$this->rows_per_page}"); if(!$rs) { if($this->debug) echo "Pagination query failed. Check your query.<br />"; return false; } return $rs; } /** * Display the link to the first page * * @access public * @param string $tag Text string to be displayed as the link. Defaults to 'First' * @return string */ function renderFirst($tag='First') { if($this->page == 1) { return $tag; } else { return '<a href="'.$this->php_self.'?page=1">'.$tag.'</a>'; } } /** * Display the link to the last page * * @access public * @param string $tag Text string to be displayed as the link. Defaults to 'Last' * @return string */ function renderLast($tag='Last') { if($this->page == $this->max_pages) { return $tag; } else { return '<a href="'.$this->php_self.'?page='.$this->max_pages.'">'.$tag.'</a>'; } } /** * Display the next link * * @access public * @param string $tag Text string to be displayed as the link. Defaults to '>>' * @return string */ function renderNext($tag=' >>') { if($this->page < $this->max_pages) { return '<a href="'.$this->php_self.'?page='.($this->page+1).'">'.$tag.'</a>'; } else { return $tag; } } /** * Display the previous link * * @access public * @param string $tag Text string to be displayed as the link. Defaults to '<<' * @return string */ function renderPrev($tag='<<') { if($this->page > 1) { return '<a href="'.$this->php_self.'?page='.($this->page-1).'">'.$tag.'</a>'; } else { return $tag; } } /** * Display the page links * * @access public * @return string */ function renderNav() { for($i=1;$i<=$this->max_pages;$i+=$this->links_per_page) { if($this->page >= $i) { $start = $i; } } if($this->max_pages > $this->links_per_page) { $end = $start+$this->links_per_page; if($end > $this->max_pages) $end = $this->max_pages+1; } else { $end = $this->max_pages; } $links = ''; for( $i=$start ; $i<$end ; $i++) { if($i == $this->page) { $links .= " $i "; } else { $links .= ' <a href="'.$this->php_self.'?page='.$i.'">'.$i.'</a> '; } } return $links; } /** * Display full pagination navigation * * @access public * @return string */ function renderFullNav() { return $this->renderFirst().' '.$this->renderPrev().' '.$this->renderNav().' '.$this->renderNext().' '.$this->renderLast(); } /** * Set debug mode * * @access public * @param bool $debug Set to TRUE to enable debug messages * @return void */ function setDebug($debug) { $this->debug = $debug; } } FYI this pagination came from the internet and there is no copyright problem in using it. Here is the link for the original script: http://phpsense.com/php/php-pagination-script.html . Last but not least, as I said when I try to go the next paginated page the results get skewed and there is an error at the top of the page that says: Notice: Undefined index: q in C:\apache\Apache2\htdocs\testing\usage.php on line 5 Line 5 is this: $q = $_GET["q"]; I know this is a huge one but I am hoping someone could help me. [attachment deleted by admin]
  10. I managed to solve the problem myself. I completely overlooked the fact that the lines that create the new folder stores the name(date time stamp) in a variable. You can then just call this variable or use it in your path where you are moving the files to.
  11. I need to move xml files from folderA to folderB. Before the are moved to folderB I need to create a subfolder in B that is named according to system date and time. I have the code to move the files from folderA to folderB: move /y C:\folderA\*.xml C:\folderB\ I have the code that creates a new folder and names it according to system time stamp of year,month,day_hours,minutes,seconds: REM Create sub directory called \yymmdd_hhmmss REM where yymmdd_hhmmss is a date_time stamp like 030902_134200 set hh=%time:~0,2% REM Since there is no leading zero for times before 10 am, have to put in REM a zero when this is run before 10 am. if "%time:~0,1%"==" " set hh=0%hh:~1,1% set yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2% md D:\batch-programming\%yymmdd_hhmmss% how do I marry the two? I need to move the file to the newly created subfolder named from timestamp in folderB.
  12. The registration form for this site check input dynamically. Once the length and strength of the password is good a small tick appears to the right of the text box. Prior to which a warning icon is present. Can someone tell me what technology they are using for this? I've tried "Dreamweaver's Spry Widgets" and a few others. Are they any good open source apps for this or is it best done manually using ajax? Are they using Ajax? Hoping the answer to this question is not a security breach?
  13. Tremendous. Thanks for you time and help.
  14. I like the logic in this solution. However, my php app is a 'live search' using ajax. So once users are logged in they basically are going to remain on the same page. If they have conducted a search and 2 mins has passed I want the page to redirect to login if they try to conduct another search. So they don't go to another page. Does your logic still apply?
  15. I am using sessions to authenticate users from page to page once they have successfully logged in at the login page. Users are funny and will not always "log out". How do I control sessions to time them out after say 120 seconds. At present my solution is to specify the seconds in the session.gc_maxlifetime and to specify garbage collection in the session.gc_probability session.gc_divisor of the php.ini file. I have specified the probability of garbage collection to 100%. I have very few users and security has to be tight. Are there any better solutions? As 100% probability of garbage collection can degrade performance.
×
×
  • 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.