PNewCode Posted January 26, 2023 Share Posted January 26, 2023 Hello. Today I'm working on making some text that a user enters (biography) show up as a popup when the button is clicked. I have managed to make the popup show the box with the title, and close correctly with some external JS and CSS What I'm failing at, is getting the value from the database. No errors are showing, and no errors in my error log on the hosting. What confuses me, is that when I put '.$row['bio'].' in other places on the page, then the value will appear, but not for this popup. Any thoughts? This is the part that is the popup. This is all within the php page inside an echo. If you need to see more, let me know and I will show it <div class="modal" id="modal"> <div class="modal-header"> <div class="title">Bio</div> <button data-close-button class="close-button">×</button> </div> <div class="modal-body">'.$row['bio'].'</div> </div> <div id="overlay"></div> Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/ Share on other sites More sharing options...
ginerjm Posted January 26, 2023 Share Posted January 26, 2023 Is this block of code wrapped in single quotes? That could be the problem since the php variable reference won't be interpreted if not. Maybe try this? echo "<div class='modal' id='modal'> <div class='modal-header'> <div class='title'>Bio</div> <button data-close-button class='close-button'>×</button> </div> <div class='modal-body'>" . $row['bio'] . "</div> </div> <div id='overlay'></div>"; Note how I began the echo with a double quote and swapped all the other doubles for singles. Now the $row reference will work. Kind of confused as to what that reference to × is supposed to be. Is that supposed to be $times? Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605076 Share on other sites More sharing options...
Barand Posted January 26, 2023 Share Posted January 26, 2023 13 minutes ago, ginerjm said: That could be the problem since the php variable reference won't be interpreted if not. Yes it will - concatenation is being used. If, however, it is html code and not something being echoed then it needs to be <div class="modal-body"> <?= $row['bio'] ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605077 Share on other sites More sharing options...
ginerjm Posted January 26, 2023 Share Posted January 26, 2023 Damn! Missed that silly little dot. Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605078 Share on other sites More sharing options...
PNewCode Posted January 26, 2023 Author Share Posted January 26, 2023 @ginerjm and @Barand thank you, but I should have told more. What I posted is actually inside an echo already. I just didn't post the whole pages script. I did try it with a double quote instead just to see if that would work but it didnt, it just made the page blank Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605079 Share on other sites More sharing options...
PNewCode Posted January 26, 2023 Author Share Posted January 26, 2023 Also, I tried <div class="modal-body">" '.$row['bio'].' "</div> based on @ginerjm post and that didn't make a blank page but didn't have any change either Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605080 Share on other sites More sharing options...
PNewCode Posted January 26, 2023 Author Share Posted January 26, 2023 Oh, sorry and @ginerjm to answer your question, the × gives the "x" to close out the popup Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605081 Share on other sites More sharing options...
ginerjm Posted January 26, 2023 Share Posted January 26, 2023 And you are not getting any error messages or warnings, which I do hope is enabled? Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605082 Share on other sites More sharing options...
PNewCode Posted January 26, 2023 Author Share Posted January 26, 2023 @ginerjmcorrect. And it is Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605083 Share on other sites More sharing options...
PNewCode Posted January 26, 2023 Author Share Posted January 26, 2023 OH WOW!!!! I'm giving myself the major stink-eye right now. I'm so sorry to waste everyones time. The reason it wasn't working is because I had the WRONG DATABASE AT THE BEGINNING OF THE FILE!!! Yup, it was looking for something that wasn't there. Good grief. I changed the database info and now it works (face palm to myself) Hhahahaha Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605084 Share on other sites More sharing options...
ginerjm Posted January 26, 2023 Share Posted January 26, 2023 Sounds like you did not have any error checking turned on... If you could not connect there should definitely (imho) have been some message. Quote Link to comment https://forums.phpfreaks.com/topic/315842-adding-mysql-value-to-popup/#findComment-1605095 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.