Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 31 Dec 2008, 08:58
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
RESOLVED Does this Query have a chance?

Not only am I pretty new to writing my own PHP code, I'm even newer at writing my own SQL queries and even newer at writing anything for vBulletin, if that makes sense...

I'm JUST starting a vBa CMPS page for a friend of mine's site and before I get too far into this, I'd like to know if this query has a chance of working, given that all of the tables and other variables are correct...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In other words, can I include a for() function in a query?

Remember, I'm just a noob at this, so if I've done something horribly wrong in my code, I'm simply just not aware of what you can and cannot do in SQL queries yet. (or PHP, apparently)

Oh, and also, this is the second query on this page. Is it possible to combine two queries if one of them contains the results of the other? (See code above)

Thanks!

[EDIT]
Realized I needed to change a couple things.
[/EDIT]

--------------- Added 31 Dec 2008 at 05:38 ---------------

I'm learning that I have a LOT to learn...

Never mind...I figured out the query I need to run, but I'm having problems with the rest of my script...

Last edited by Dax IX; 02 Jan 2009 at 07:12. Reason: Auto-Merged DoublePost
Reply With Quote
  #2  
Old 31 Dec 2008, 10:48
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #3  
Old 31 Dec 2008, 11:02
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
Thank you so much. That just shortened everything quite nicely.

Now I'm just having issues with everything else.

I'm desperately trying to learn PHP and vBulletin functions all at the same time in as little time as possible. Kinda messing me up here...

Sorry for being such a (n OR b)oob.

--------------- Added 31 Dec 2008 at 12:50 ---------------

Okay, I've figured most of it out now (yes, I've been searching, not just asking ), but I'm coming across a problem (My fault, I'm sure. I'm not afraid to say that I know almost nothing here).

In my database I've entered bogus "menus" and "planners".

With:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I'm only getting one row as a result. (Array ( [id] => 1 [shortdescription] => my first breakfast menu ) 1)

How do I get an array with all results? (Please don't shoot me )

Maybe I should mention that I changed my code a little, so the whole implode() function wasn't necessary. $menuids was already "1,2,3,4".

Last edited by Dax IX; 31 Dec 2008 at 12:50. Reason: Auto-Merged DoublePost
Reply With Quote
  #4  
Old 31 Dec 2008, 16:53
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Probably something more along these lines:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #5  
Old 01 Jan 2009, 04:29
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
This is what you want:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #6  
Old 01 Jan 2009, 18:39
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
Thanks.

I was able to get sort of the results that I want, but now the problem is that I need to have them sorted in the order that is called for in $menuids.

For example, $menuids is supposed to be "5,10,3,1,4,7", but it's returning the results in numerical order ASC.

I've tried using array_multisort(), but one of the arrays is a multi-dimensional array, and one is not, so it's not working...in other words, I've turned the data in $menuids into an array and tried sorting $menus_array with it. Nope. Didn't work...

I'm just taking stabs in the dark here. If I should post my script code, I will.

Thank you all for your assistance.
Reply With Quote
  #7  
Old 02 Jan 2009, 04:17
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
MySQL will automatically sort by the primary key if no order clause is specified in a query. Dirty way is below, I can't think of anything else off the top of my head.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #8  
Old 02 Jan 2009, 05:19
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
Thank you.

Now the problem I'm having is how to actually call the [shortdescription] from my query with this information.

Grrr...I really should know how to do this, but I'm just not getting it. I admit, I haven't gone through learning PHP from the beginning, but instead I just dive right in and seemingly waste people's time.

But, with this new info, how would I call the [shortdescription] for each table cell that I'm putting these in?

Here's some context:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And here's the page:

http://www.whatz4dinner.com/portal.php?pageid=planner
(I know you can't see the results, but this is the format)

Thank you so much for helping me with this.

Last edited by Dax IX; 02 Jan 2009 at 05:33.
Reply With Quote
  #9  
Old 02 Jan 2009, 05:51
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
I don't see why you needed to results in any specific order. Replace what I posted before with this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

You can call "shortdescription" like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #10  
Old 02 Jan 2009, 06:11
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
The reason is because of the way I have the table filled. It's a vertical loop of sorts, but I guess I could just reorder [menuids] and fill the table horizontally.

Thank you so much for your help. I'll go in and see what I can do.
Reply With Quote
  #11  
Old 02 Jan 2009, 06:32
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
You don't seem to be looping the $menus_array, but rather, just referencing it using a set key. So I don't know what the order of the array has to do with anything.
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #12  
Old 02 Jan 2009, 06:45
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
I'll study it a little more, but this seems to give me EXACTLY what I'm looking for:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Thank you so much for your help!

I'm not sure exactly how yet, but originally it was listing the menu descriptions in the order that they were entered into the database instead of by the order that they're listed in $menuids. But with your help I was able to get them to display exactly how I want them.

Thank you again!

--------------- Added 02 Jan 2009 at 06:56 ---------------

Unless you have something that you really want to point out with this script the way I have it, this can be marked as SOLVED.

Thanks again!

Last edited by Dax IX; 02 Jan 2009 at 06:56. Reason: Auto-Merged DoublePost
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 04:24.

Layout Options | Width: Wide Color: