Jump to content

devofash

Members
  • Posts

    81
  • Joined

  • Last visited

    Never

Everything posted by devofash

  1. its just assigning $_POST['name'] values to $name so in ur insert u wouldnt have to go [code] INSERT INTO table ('', '$_POST[name]' ....) [/code] instead you would just do [code] INSERT INTO table ('', '$name' .....) [/code] less chances to make mistakes tht way ;) ........ also it doesnt have to be the same name i.e. you can have $anything = $_POST['name']
  2. php has its own function called `reverse array` use that ..... something like : [code] // your array $array = array (1,2,3,4,5,6); //apply`reverse array to it` $reverse = array_reverse($array); [/code]
  3. works perfectly :D thanx......... got another question regarding the same topic ofcourse so for e.g. .... if i have a form with "10 combo boxs", "10 text boxes", "10 hidden fields", and "10 radio buttons" ...... so that would mean i have to use the "switch case" thing....... and write em out seperately like so: [code] // some code switch($k) {             case 'submit':                 break; // do nothing             // 10 text boxes             case 'lname':             case 'fname':             case 'address':                $qtmp[] = // the rest             break;            // 10 combo boxes           case 'department':           case 'jobs':               $qtmp[] = // the rest          break;          // etc ... etc... [/code] is that right ???
  4. thanx for the explination ermm....... still getting an error though [code] Error with query: insert into test set Array, fname = 'john', lname = 'smith', address = 'none', email = 'me@me.com' You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' fname = 'john', lname = 'smith', address = 'none', email = 'me@me.com'' at line 1 [/code] [code] normally in insert u have $q = "SELECT INTO table VALUES ....";   [/code] but the code above doesnt could that be the reason ?? soz this method is very new to me ..... i cant really spot wht's wrong with the insert..statement ..
  5. do something like this: [code] <?php $id = $_GET['id']   // Get the value in id and then use the switch to decide what page to display switch($id) {   default:   include('home.html');   break;   case "home":   include('home.html');   break;   ...   ... } ?> [/code]
  6. you can use javascript to do this .... its called onClick ... when a user clicks on the text box it empties it (or you can say fills it with an empty string) [code]<INPUT TYPE="text" NAME="text_field" VALUE="somevalue" onClick="this.value=''">[/code]
  7. ooo i know about switch and case ........ i just wanted to know why i need it in this method...... and you code gives and error [code]Warning: implode() [function.implode]: Argument to implode must be an array. on line 48 [/code]
  8. does anyone also have a link to tutorails or something which could explain this method !!
  9. that works :) ......... but what if i want to pass more then one variable ....say for e.g. i want to pass 10 variables.... then it would be a little u know... for now it works though.... if anyone has a solution plz lemme know :D
  10. thanx.......... ermm could you plz explain some thing though .... what's the switch and all those cases for ... do i need em ??
  11. hey ppl.... got another question ... hope you can help me out. here it goes.. say if i got a form with 40 fields and i want to validate and insert them into the database... Right now the only way i know is i got to do [code] <form action='whatever.php' method='post'>   <input type='text' name='fname'>   <input type='text' name='lname'>   .....   .....   <input type='submit' value='submit'> </form> [/code] [code] <?   ....   ...   // do error checking, if everything is ok, insert data    $sql = "INSERT INTO table_name ($fname, $lname ......)               VALUES ('$_POST[fname]', '$_POST[lname]' ....)"; [/code] now 40 form fields and inserting/validating is gonna be long ..... there's gotta be a simpler way to do this. maybe get form data into an array or something validate it and then enter them into the db... but i'm a newbie dont really know how to do it......... can anyone provide me with an snipplet (with explaination) on how i can go about doing this thanx in advance
  12. ok so this is what i've done so far .... it sorta works..... here's the code [code] <?      $link = $_GET['link'];      if($link == approve)      {        echo approve();      }      function pending()      {        // some stuff         <td> <a href = \"?page=pending_job&link=approve&jobID=$jobID\">        Approve </a></td>        return $email;      }      function inform_user($email)      {        global $email;           $subject = "blah";           $message="blah";        mail($email, $subject, $message,           "From: ORS Webmaster<me@somedomain.com>\n            X-Mailer: PHP/" . phpversion());            echo "Mail has been sent";      }      function approve()      {        global $email;            // update record        if($result)        {          echo $email;          inform_user($email);        }      }      $email = pending();      inform_user($email);   ?> [/code] i want it to send email to a person who's record is updated, after i press the approve link (thts when the record gets updated) right now it just send an email to the last entry every time page is refreshed.
  13. ermmm need it to send email when a record gets updated..... and tht's why perviously i was calling the inform_user() inside the approve function .... how would i do tht ?
  14. it doesnt seem to work... !! *confused*
  15. there are several ways to display data from mysql database here's the way i do it [code] <?php      $hostname = localhost;      $username = username;      $password = password;      $db = mysql_connect($hostname, $username, $password) or die(mysql_error());      $connection  = mysql_select_db("mydb", $db);      $sql = "SELECT fname, lname FROM table_name";      $result = mysql_query($sql, $connection);      while ($rows = mysql_fetch_array($result))      {        $fname = $rows['fname'];        $lname = $rows['lname'];        echo $fname;        echo $lname;      } ?> [/code] i'm havent tested it..... i probably missed a semi colon somewhere .. but it should be alrite .... and a simple google search will give u lots and lots of info on using php/mysql :)
  16. hello ppl got a question........ its quite silly one too *embarassed* am trying to send an email after a query is updated..... but am getting an error saying : Warning: mail() [function.mail]: SMTP server response: 554 Error: no valid recipients in C:\Program Files\xampp\htdocs\project\pending_job.php on line 131 here's the code below...... i think i need to pass $email into inform_user() but dont know how to ?? also can anyone suggest a better way of doing this..... it seems to me that i'm doing it the long way !! [code]      function pending()      {              // some stuff      }         function update()         {             // update query              }      function inform_user()      {                mail($email, $subject, $message,           "From: ORS Webmaster<me@domain.com>\n           X-Mailer: PHP/" . phpversion());      } [/code]
  17. i've done it ........ was really tired yesterday ..... couldnt think properly........ thread SOLVED ....... thanx once again barand for all the help :)
  18. action='index.php?display_jobs&department=$id' is that it... but its not working either soz this is very embarassing but how do i do that....? ..... dont get combo boxes shoul've never used it in the first place
  19. i have an index page where i've got somethin like this [code]$page = $_GET['page'] switch($page) {   case "display_jobs":   include('display_jobs.php');   break; }[/code] but dont c wht that one has to do with this script... ? ... how do i get this one to work.. sorie i'm being really silly just get very frustrated when my code dont work and i start being dumb :S
  20. there a tutorial on php freaks tutorial section ........ where a user registers and they are sent an email only after clicking the validation link ..... they can successfully login to the system... have a look at that script ........ maybe tht will help you :)
  21. because in all the other pages that i've got i've done that.... need to stay consistent..... and i thought using the query_string thing was efficient.
  22. [!--quoteo(post=364625:date=Apr 14 2006, 12:06 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 14 2006, 12:06 AM) [snapback]364625[/snapback][/div][div class=\'quotemain\'][!--quotec--] Why is the action in php tags when there is no php code? [code]<form name = 'form' method='GET' action='?page=display_jobs'>[/code] [/quote] still doesnt work. if i put <form action = 'display_jobs.php'> it works perfectly..... but need to use QUERY_STRING so have to put <form action = '?page=display_jobs'> ...... but still doesnt work ... so dont know wth to do ...? basicallly all i need to do is get data from a database table into the combo box, when user clicks a record .... alll the data related to that record is displayed into a page. i.e.... user picks "Human Resources" presses submit... all the jobs from tht department is displayed into another page. script works if i put 'display_jobs.php' but instead i need to do '?page=display_jobs'.... any help will be appreicated :D ....... also i would much appreciate it if someone can tell me if the above posted code can be made better or if there's a shorter way of doing what i've done. thanx in advance
  23. dont want to make another thread .... just need a little help with somethin ... its related to this topic so... here goes. the script listed at the end ... works fine .... except for one little problem .. the problem: when i do this it works fine .... [code]       <form name = 'form' method='GET' action=display_jobs.php > [/code] [code]       <form name = 'form' method='GET' action= <? ?page=display_jobs ?> > [/code] ^^ but when i do this it doesnt work. i need to use this method instead of the first one can anyone help ... plz ...... thanx
  24. hmm solved...... i just passed the value to another query .... used get to get the value....ran a query on that value and displayed the matching records :) ............. cant believe i didnt thing of tht before... it just didnt crosss my mind :duh: thanx barand........ apreciate ur help :)
×
×
  • 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.