Jump to content

phpnewbie25

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phpnewbie25's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I need help with customised sorting, below shows a table being populated by an SQL database. how would I be able to choose which row is sorting it? like if i clicked the top of one row it would sort it by that one? Thanks in advance <html> <head> <title>View Contacts</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <H1 ALIGN=center><IMG SRC="Images/logo.jpg" ALT="IOM Logo"></H1> <p align=center> <table table border='1' cellspacing=5 bgcolor=darkgray> <tr><td>ID</a></td><td>First Name</td><td>Last Name</td><td>Organisation</td><td>Address</td><td>Email</td><td>Phone</td><td>Fax</td></tr> <?php while($row=mysql_fetch_array($getUser)) { echo" <tr bgcolor=lightgray> <td>$row[id]</td> <td>$row[first_name]</td> <td>$row[last_name]</td> <td>$row[organisation]</td> <td>$row[address]</td> <td>$row[email]</td> <td>$row[phone]</td> <td>$row[fax]</td> </tr>"; } ?> </table> </p>
  2. Hi, Just testing this out now, no values are being passed to GET/POST functions, have been toying around with it but getting nowhere, any ideas? Thanks <?php include "dbConfig.php"; if (isset ($_POST['submit'])) { echo 'first loop reached'; $test = $_POST['first_name']; echo 'Post test: '.$test; $firstname = $_GET['first_name']; echo 'Get test: '.$firstname; $sql = "DELETE * FROM users WHERE id='".$_GET['id']."'"; $result = mysql_query($sql) or die(mysql_error()); if (mysql_affected_rows()> 0) { echo 'User Deleted'; } else { echo 'Not Deleted'; } } $getUser_sql = 'SELECT * FROM users'; $getUser = mysql_query($getUser_sql); ?> <html> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select name='name' style=" color:blue;text-align:left" size='21'> <option value="" style="text-align:center">-Select User from List-</option> <?php while ($row = mysql_fetch_array($getUser)) { ?> <option value =" <?php echo $row['id']; ?>"> <?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?></option> <?php } mysql_free_result($getUser)?> <? echo ' &nbsp'; ?><input name="submit" value="Delete User" type="submit" /> </form> </html>
  3. many thanks for the reply, in work at the moment so will test it and tweak it when I get home. cheers
  4. Hi, I have a select box that has its values populated from a db. I'm trying to develop a page so that beside this select box there is a delete button that will delete whichever row is selected from the select box from the db. Very new to php so excuse the state of my current code! Here's what I have so far: Any help greatly appreciated. <?php session_start(); include "dbConfig.php"; $getUser_sql = 'SELECT * FROM users'; $getUser = mysql_query($getUser_sql); ?> <select name="select" style="width:250" style="color:blue;text-align:left" size='21'> <option value="0" style="text-align:center">-Select User from List-</option> <?php while ( $row = mysql_fetch_array($getUser) ) {?> <option value="<?php echo $row['first_name']; ?>"> <?php echo $row['id']; ?> <?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?> </option> <?php } ?> <html> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php echo $selectMenu; ?> <input type="submit" /> </form> </html>
×
×
  • 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.