Jump to content

Search the Community

Showing results for tags '#sql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Hey! I'm fetching data frmo my database and displaying it in a table. Now I want to be able to display that data but sorted in different ways. Right now it's sorted by id ASC. I want to make the <th> links, so when i press one of them, the page will sort the data in that way. How can I make this without writing a lot of new querys? I want to use the one query i already have made. Here is my code: <?php if(isset($_GET['hpid'])) { $hpid = (int)$_GET['hpid']; $test = mysql_query("SELECT * FROM `project`, `users`, `projectStatus` WHERE `projectHuvudId` = $hpid AND project.projectCreatorId = users.user_Id AND project.projectStatusId = projectStatus.statusId"); $test2 = mysql_query("SELECT p.projektName , p.projectId , s1.statusName , u1.username as creatorName , u2.username as ansvarig , p.projectDescription , p.projectCreateDate , p.projectStartDate , p.projectEndDate FROM project p INNER JOIN users u1 ON p.projectCreatorId = u1.user_Id INNER JOIN users u2 ON p.projectAnsvarig = u2.user_Id INNER JOIN projectStatus s1 ON p.projectStatusId = s1.statusId WHERE `projectHuvudId` = $hpid ORDER BY p.projectId ASC"); ?> <table class="display"> <th>ID</th> <th>Skapat</th> <th>Namn</th> <th>Start</th> <th>Slut</th> <th>Skapare</th> <th>Ansvarig</th> <th>Status</th> <?php while($row = mysql_fetch_assoc($test2)) { ?> <tr> <td><?php echo "<a href='project.php?pid=" . $row['projectId'] . "'>" . $row['projectId'] . "</a>"; ?></td> <td><?php echo $row['projectCreateDate'] ?></td> <td><?php echo $row['projektName'] ?></td> <td><?php echo $row['projectStartDate'] ?></td> <td><?php echo $row['projectEndDate'] ?></td> <td><?php echo $row['creatorName'] ?></td> <td><?php echo $row['ansvarig'] ?></td> <td><?php echo $row['statusName'] ?></td> </tr> <?php } ?> </table><?php } ?>
  2. Hey! I have these tables: Project: name - name of project creatorId - id which is related to id 'userId' in table called Users. This table also have name of user and surname of user. statusId - id which is related to id 'statusId' in table called Status. This table also have Started, Ended, Closed. assigneId - id which is related to id 'userId' in table called Users. This table also have name of user and surname of user. (relation same as creatorId). I think I have given you everything relevant. Now to my question.. How can I query this so I can get all information I want? I'm getting what I want really, but problem is that I want name of creatorId and assigneId, not just ID. How can I do this in 1 query?
×
×
  • 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.