Jump to content

Replace output from MySQL Select Quary


Syekiya

Recommended Posts

Hi there!

 

My current output is the following:

 

ID Name Logged In GM E-Mail Banned 
1  Admin_Zack  0  4   0  
4  itsaname  2  0   0  
5  GUEST1  0  0   0  
6  Branden  2  4  [email protected]  0  
7  Account  0  0   0  

 

What I want to do is the following:

If Logged in is 2, replace the number 2 with the word Yes.

 

 

Here is my script!

 

 

Please Note: Ignore $content .=

This is used on a CMS that uses $content .= as a placeholder on where to put the information!

 

$con = mysql_connect($dbhost, $dbuser, $dbpass);
$update = $_POST['UpdateEmail'];




mysql_select_db($dbname, $con);
$members = mysql_query ('SELECT * FROM accounts') or die ('Error: '.mysql_error ());
$content .= "
<center>
<table border=\"1\">
<tr>
<th>ID</th><th>Name</th><th>Logged In</th><th>GM</th><th>E-Mail</th><th>Banned</th>
</tr>
";

// $banned = str_replace({$row['banned']}, "Yes");

while($row = mysql_fetch_array($members, MYSQL_ASSOC))
{

$content .= "
<tr>
<td> {$row['id']} </td>
<td> {$row['name']} </td>
<td> {$row['loggedin']} </td>
<td> {$row['gm']} </td>
<td> {$row['email']} </td>
<td> {$row['banned']} </td>
</tr>
";
}
$content .= "</table></center></div>";

if ($update != $null) {
mysql_select_db($dbname, $con);
mysql_query("UPDATE accounts
INNER JOIN phpbb_users 
SET accounts.email = phpbb_users.user_email
WHERE accounts.name = phpbb_users.username");
header( 'Location: http://www.mapleluv.com/index.php?pid=4' ) ;

}

$content .= "
<center>
<br><br>
<form action=\"http://www.mapleluv.com/index.php?pid=4\" method=\"post\">
<input type=\"submit\" value=\"Update E-Mail Addresses\" name=\"UpdateEmail\"
</form>
</center>
";


?>

 

 

 

Thank you very much!

Syekiya

Link to comment
https://forums.phpfreaks.com/topic/153484-replace-output-from-mysql-select-quary/
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.