Syekiya Posted April 10, 2009 Share Posted April 10, 2009 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 More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 That's not how str_replace is used. It's str_replace(exist, replace, string) Link to comment https://forums.phpfreaks.com/topic/153484-replace-output-from-mysql-select-quary/#findComment-806442 Share on other sites More sharing options...
Syekiya Posted April 10, 2009 Author Share Posted April 10, 2009 Okay, so how would I implament this? Link to comment https://forums.phpfreaks.com/topic/153484-replace-output-from-mysql-select-quary/#findComment-806453 Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 $banned = str_replace(2, "Yes", $row['banned']); Does that work? However, I am curious why you can't just do this: if($row['banned'] == 2) { $banned = 'Yes'; } Link to comment https://forums.phpfreaks.com/topic/153484-replace-output-from-mysql-select-quary/#findComment-806472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.