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
https://forums.phpfreaks.com/topic/22129-phpmysql-help-rows/
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
https://forums.phpfreaks.com/topic/22129-phpmysql-help-rows/#findComment-99135
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
https://forums.phpfreaks.com/topic/22129-phpmysql-help-rows/#findComment-99199
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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