Jump to content

typicalalex1

Members
  • Posts

    3
  • Joined

  • Last visited

typicalalex1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wow this is confusing What i want to do is have a HTML form with several textboxes. These textboxes are populated from a mySQL table when the page opens. I need a way of navigating through the records using 2 buttons, Next and Previous. Im trying to do this using Ajax, but i cant seem to find any good examples. Any chance you can point me in the right direction? Thanks
  2. Thank you for the reply. Its quite a big project which is going to take up a lot of my time, so i dont want to want a solution without knowing its the best way of doing it. I will have a look into Ajax as well. Thanks for the advice
  3. Hi guys. I have been learning PHP for a couple of months now for a project at work. I need to display database records on a HTML form which i have managed to do. I have added 2 buttons that allow the users to select the next or previous record. This works fine. The form is setup to submit to the same page the form is held on. As you can see, i have setup 2 if statements at the start. These check to see what button was pressed (next or previous). I want to know if i have done this using the best method? From what i can tell, everytime Next or Previous is pressed, the entire webpage is recreated. Is there a better way of doing this or have i done this correctly? I have removed most of the code from this example because there are a lot more textboxes and other controls on the form. #CONNECT TO SQL #SELECT DATABASE $query = "select * from tblEmployees where employeeID = $i"; $rs = mysql_query($query); $row = mysql_fetch_array($rs); #IF NEXT WAS PRESSED if (isset($_POST['btnNext'])){ $i = $_POST['txtEmployee']; $i++; $query = "select * from tblEmployees where employeeID = $i"; $rs = mysql_query($query); $row = mysql_fetch_array($rs); } #IF PREVIOUS WAS PRESSED if (isset($_POST['btnPrevious'])){ $i = $_POST['txtEmployee']; $i--; $query = "select * from tblEmployees where employeeID = $i"; $rs = mysql_query($query); $row = mysql_fetch_array($rs); } ?> <form action="" method="post" id="frmMain" style="display:inline-block;background-color:lightgray" align ="center"> <table> <tr> <input name="txtEmployee" type="text" size="22" maxlength="30" value= <?php echo $i ?>> <td><p>Title:</p></td> <td><input type="text" style="border:1px solid" name="txtTitle" size="5"></td> <td><p>First Name:</p></td> <td><input name="txtFirstName" style="border:1px solid" type="text" size="15" value='<?php echo $row['firstName'] ?>'></td> <td><p>Surname:</p></td> <td><input name="txtLastName" style="border:1px solid" type="text" size="15" value='<?php echo $row['lastName'] ?>'></td> <td><p>Status:</p></td> <td><input name="txtStatus" style="border:1px solid" type="text" size="15" value='<?php echo $row['status'] ?>'></td> </tr> </table> <table> <tr> <td><input type="submit" name="btnPrevious" value="Previous"/></td> <td><input type="submit" name="btnNext" value="Next"/></td> </tr> </table> </form>
×
×
  • 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.