Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member Harmonic's Avatar
    Join Date
    Jan 2011
    Location
    Toronto
    Posts
    291
    Member #
    26468
    Liked
    23 times
    Hello all, been a while since I've posted even though I've been checking in and reading every once in a while.

    Basically as a side project and learning experience, I've been developing my own CRM for personal use using PHP and mySQL.

    I have everything looking and working beautifully, and now the only thing left for me to do is change the order that one of my lists prints in.

    My current QUERY is like this...

    Code:
    $data = mysql_query("SELECT v1,v2,v3,v4,v5,v6 FROM database_name WHERE v1= '".$v1."'" ) or die(mysql_error());
    This QUERY successfully gets all the information I want, and I then use a simple loop to print everything. The problem is that the loop rightfully prints in the order the table rows were saved in. I want to print out the information in alphabetically order according to v1.

    The following code obviously does not work, but is an idea of what i'm trying to accomplish.

    Code:
    $data = mysql_query("SELECT v1,v2,v3,v4,v5,v6 FROM database_name WHERE v1= '".$v1."'" ORDER BY v1) or die(mysql_error());
    Is there an easy way to grab the information in the desired order from the query, or would it be best to just sort it all in the loop?

    Thanks for any help/advice!

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You gotta move your quote over, dude.
    Code:
    $data = mysql_query("SELECT v1,v2,v3,v4,v5,v6 FROM database_name WHERE v1= '".$v1."' ORDER BY v1") or  die(mysql_error());
    But in this case, if your v1 is what you're filtering, you're not going to see any change in the results since your v1s will all be the same.

    So you'll probably just want to remove the filter:
    Code:
    $data = mysql_query("SELECT v1,v2,v3,v4,v5,v6 FROM database_name ORDER BY v1") or  die(mysql_error());
    * - code syntax may not entirely be correct. I'm not primarily a PHP guy.
    Harmonic likes this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Oh yeah, and hi, welcome back, and why the heck don't you post anymore? I shouldn't have answered your question for you, you...non-poster, you!
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  5. #4
    Senior Member Harmonic's Avatar
    Join Date
    Jan 2011
    Location
    Toronto
    Posts
    291
    Member #
    26468
    Liked
    23 times
    Game, THANKS! Wow I feel like an idiot. When you are so wrapped up in a project and the weather is so hot, it's easy to miss these stupid syntax errors. Correcting this has the output formatted exactly like i wanted. Thanks again!

    PS: Guess you guilted me into posting more I'll keep an eye out for posts I can contribute to again haha.

  6. #5
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    That's what I wanted to hear! It can't all be me, Mare, Wired, George, shovenose, MYIW, Webzarus and the other 5 or 10 people I haven't listed here. We need MOAR!
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Thanks for the compliment...but I still had to remove the link drop.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:19 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com