Raine Dragon Posted January 3, 2009 Share Posted January 3, 2009 So, I'm pretty sure this is a pretty basic thing, but I'm a bit of a self-taught beginner to php, and I haven't been able to figure it out yet. I have a table, and I run a query on it $sql = "SELECT * FROM task_users WHERE UserID = $userdataID "; $result= mysql_query($sql); if (mysql_numrows($result) !=0) { $numrows = (mysql_numrows($result)); while($row = mysql_fetch_row($result)) { $TaskID= $row[2]; $DateAccept= $row[3]; $UserStats= $row[4]; } So, I get back my one result, and it works fine. But it's just one result. x_x But, I want all of the records where the userID is equal to the variable $userdataID. Which, I know is possible, and I'm pretty sure needs some sort of loop, but for the life of me, I can't figure out how to do it, and I can't seem to find a solution online because it is such a simple thing and there are so many other things that contain the same words I've tried searching by. x_x I would very much appreciate any kind of help! Link to comment https://forums.phpfreaks.com/topic/139353-help-me-select-multiple-records-from-a-database/ Share on other sites More sharing options...
rarebit Posted January 3, 2009 Share Posted January 3, 2009 It basically looks right to me, i'm thing it's the WHERE ID clause, are you sure you have multiple users with a single ID (sounds abnormal)? Also i'd change this: if (mysql_numrows($result) !=0) { $numrows = (mysql_numrows($result)); to $numrows = mysql_numrows($result); if ($numrows !=0) { Link to comment https://forums.phpfreaks.com/topic/139353-help-me-select-multiple-records-from-a-database/#findComment-728905 Share on other sites More sharing options...
Raine Dragon Posted January 3, 2009 Author Share Posted January 3, 2009 I'm sorry, I should have been more clear. Prior to this, I get the userID from a different table and it is set to be equal to the variable $userdataID. The table that this goes through has a list of tasks or jobs. Each task can be assigned to one user, but each user can be assigned to multiple tasks. (like someone might be assigned to making a banner and sending out an e-mail.. but I don't need two people to do the same thing.) So I want to select all the tasks that are assigned to the user who is looking at the page. As it stands, this only selects one task. Link to comment https://forums.phpfreaks.com/topic/139353-help-me-select-multiple-records-from-a-database/#findComment-728908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.