Jump to content

inserting php in a row in mysql


convict-snipe

Recommended Posts

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 :(

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;
}
}

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.