convict-snipe Posted October 13, 2007 Share Posted October 13, 2007 hi im trying to insert php code inside a row. http://www.thebnclan.net/forgotten/ If you look at the left col, thats where im trying to insert the php code. How can i do this? Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/ Share on other sites More sharing options...
pocobueno1388 Posted October 13, 2007 Share Posted October 13, 2007 It would be easier if you told us what you were doing, and what the problem was. Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368708 Share on other sites More sharing options...
marcus Posted October 13, 2007 Share Posted October 13, 2007 Even if you tried to echo it, it will be outputted and buffered as HTML. Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368711 Share on other sites More sharing options...
convict-snipe Posted October 13, 2007 Author Share Posted October 13, 2007 i told u my problem .. it wont show the php that i put in .. what would i need to do so it does show up.. do i need to use a function or what? Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368715 Share on other sites More sharing options...
pocobueno1388 Posted October 13, 2007 Share Posted October 13, 2007 Does the file have a .php extension? Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368722 Share on other sites More sharing options...
convict-snipe Posted October 13, 2007 Author Share Posted October 13, 2007 Here ill tell u what im doing.. Im trying to make one of those content boxes on my site get the latest users that registered. Now in order to do this i need to do $result = mysql_query("SELECT * FROM users"); << sumthing like that and that is php but i dont no how to get it in the content boxes since the content boxes are being called from the database and i made it so i can add,edit, and delete content boxes from the admin panel. Is there a way that if i type sumthing in the content box such as users it will get all the users. i dont no what i can do plz help Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368733 Share on other sites More sharing options...
trq Posted October 13, 2007 Share Posted October 13, 2007 Generally speaking, if you need to dynamically include php code from a database, your doing something wrong. You can try using eval on the code pulled from the database, but be far warned that this opens up a whole can of security issues. Re-read my first sentence. Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368858 Share on other sites More sharing options...
kratsg Posted October 13, 2007 Share Posted October 13, 2007 $number = 5;//number of new users to display $query = mysql_query("SELECT 'username' FROM `users` SORT BY 'registered_timestamp' DESC LIMIT $number"); while($row = mysql_fetch_array($query)){ echo $row['username']."<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368860 Share on other sites More sharing options...
kratsg Posted October 14, 2007 Share Posted October 14, 2007 For multiple uses, such as richest user, etc... This is an example of a function to switch based on what you need. function content_box($switch) { $number = 5;//number of items to display switch($switch) { case "newest": $query = mysql_query("SELECT 'username' FROM `users` SORT BY 'registered_timestamp' DESC LIMIT $number"); while($row = mysql_fetch_array($query)){ echo $row['username']."<br>"; } break; case "richest": $query = mysql_query("SELECT 'username' FROM `users` SORT BY 'money' DESC LIMIT $number"); while($row = mysql_fetch_array($query)){ echo $row['username']."<br>"; } break; } } Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368867 Share on other sites More sharing options...
convict-snipe Posted October 14, 2007 Author Share Posted October 14, 2007 thx Quote Link to comment https://forums.phpfreaks.com/topic/73109-inserting-php-in-a-row-in-mysql/#findComment-368916 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.