Jump to content

PHP/MySQL Help (rows)


esahp

Recommended Posts

I'm creating a script that will let me accept/reject signups. I'm stuck on how to make a button to Accept/Reject each signup. Each signup is a row in a mysql table, and it's also displayed like that in html using tables. My question is how would I perform an action on the row the button is near. MySQL is still very new to me so I'm having a hard time figuring out if I need to focus more on the PHP side or SQL side.
Heres how its setup now: http://i10.tinypic.com/2qcngk5.png
[code]
<?PHP
  include "db.php";
  $query = "SELECT `fname`, `lname`, `email`, `phone`, `address`, `citystate`, `country`, `domain`, `username`, `password`, `rules`, `legal`, `atleast18`, `details`, `aboutus`, `ip` FROM users WHERE `status` = '1'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  echo "<table border='1'>";
  echo "<tr><th>Full Name</th><th>Last Name</th><th>Email</th><th>Phone</th><th>Address</th><th>City/State</th><th>Country</th><th>Domain</th><th>Username</th><th>Password</th><th>Rules</th><th>Legal</th><th>18?</th><th>Details</th><th>About us?</th><th>IP</th></tr>";
  while ($data = mysql_fetch_array($result)) {
    echo "<tr><td>";
    echo $data['fname'];
    echo "</td><td>";
    echo $data['lname'];
    echo "</td><td>";
    echo $data['email'];
    echo "</td><td>";
    echo $data['phone'];
    echo "</td><td>";
    echo $data['address'];
    echo "</td><td>";
    echo $data['citystate'];
    echo "</td><td>";
    echo $data['country'];
    echo "</td><td>";
    echo $data['domain'];
    echo "</td><td>";
    echo $data['username'];
    echo "</td><td>";
    echo $data['password'];
    echo "</td><td>";
    echo $data['rules'];
    echo "</td><td>";
    echo $data['legal'];
    echo "</td><td>";
    echo $data['atleast18'];
    echo "</td><td>";
    echo $data['details'];
    echo "</td><td>";
    echo $data['aboutus'];
    echo "</td><td>";
    echo $data['ip'];
    echo "</td></tr>";
  }
  echo "</table>";
  mysql_free_result($result);
  mysql_close($mlink);
?>
[/code]
Link to comment
Share on other sites

Well 2 things, please md5 the passwords so they won't get stolen so easily.

2nd thing. When they sign up, if you want to give the option of keeping the name/info in the database but decline their signup, then add another field to that row called "accept". 0 is no, 1 is yes.

Then on this part that echos all the information, simply put some form buttons at the bottom that tells whether or not to accept the person. YES = 1 NO = 0.

Onto your page where it gets the info, what you want to do is read this from the form. Once it reads 0 or 1, simply update that row with the answer 0 or 1 (yes or no) and there you go. Then from your site, have it display users with the field accept that equals 1. WHA LA.
Link to comment
Share on other sites

I don't understand how to tell the rows apart. I've added a new part in the table for the Accept/Reject button, and the buttons themselves, I just have no clue how to make the buttons update the row that it sits on.
[code]
<?PHP
  include "db.php";
  $query = "SELECT `fname`, `lname`, `email`, `phone`, `address`, `citystate`, `country`, `domain`, `username`, `password`, `rules`, `legal`, `atleast18`, `details`, `aboutus`, `ip` FROM users WHERE `status` = '1'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  echo "<table border='1'>";
  echo "<tr><th>Full Name</th><th>Last Name</th><th>Email</th><th>Phone</th><th>Address</th><th>City/State</th><th>Country</th><th>Domain</th><th>Username</th><th>Password</th><th>Rules</th><th>Legal</th><th>18?</th><th>Details</th><th>About us?</th><th>IP</th><th>A/R</th></tr>";
  while ($data = mysql_fetch_array($result)) {
    echo "<tr><td>";
    echo $data['fname'];
    echo "</td><td>";
    echo $data['lname'];
    echo "</td><td>";
    echo $data['email'];
    echo "</td><td>";
    echo $data['phone'];
    echo "</td><td>";
    echo $data['address'];
    echo "</td><td>";
    echo $data['citystate'];
    echo "</td><td>";
    echo $data['country'];
    echo "</td><td>";
    echo $data['domain'];
    echo "</td><td>";
    echo $data['username'];
    echo "</td><td>";
    echo $data['password'];
    echo "</td><td>";
    echo $data['rules'];
    echo "</td><td>";
    echo $data['legal'];
    echo "</td><td>";
    echo $data['atleast18'];
    echo "</td><td>";
    echo $data['details'];
    echo "</td><td>";
    echo $data['aboutus'];
    echo "</td><td>";
    echo $data['ip'];
    echo "</td><td>";
    echo "<form action=\"blah.php\" method=\"post\"><input type=\"submit\" value=\"A\">";
    echo "<input type=\"submit\" value=\"R\"></form>";
    echo "</td></tr>";
  }
  echo "</table>";
  mysql_free_result($result);
  mysql_close($mlink);
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.