tysons engineer's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
5 (0.01 per day)
Joined:
28-September 12
Profile Views:
92
Last Active:
User is offline Oct 01 2012 11:57 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   tysons engineer has not set their status

Posts I've Made

  1. In Topic: Using a function within a loop to update mysql database field

    Posted 1 Oct 2012

    View Poste_i_pi, on 28 September 2012 - 07:30 PM, said:

    The @ symbol in SQL simply means "variable". There's no point looking up @rank, it would be like searching for $myVariable.

    If you're looking to order by the variable, you should be able to use the clause ORDER BY @rank. If that doesn't work, then you can wrap your statement in another SELECT and then use the ORDER BY, like this:
    SELECT *
    FROM (
      // Enter the other query here
    ) AS SubQuery
    ORDER BY rank
    
    


    I just realized, this wont help me. The ranking will not actually renumber back to 1, 2, 3, 4 which is the problem I am having with being two columns.

    Right now I have two recordsets one for even, one for odd. If I add that rank function to each of those recordsets it will still output

    1 4
    3 6
    9 8

    Which is not going to work. That is why I wanted to set up a second variable that actually goes to a field in the database that arches over both record sets.

    So I guess is there anyway someone can help explain why my output to the SQL table isnt taking?

    As a broad overview of the function I am trying to get to;

    Page loads
    1 recordset takes all of categorized post_id# (1, 2, 4, 5, 8, 12...etc) and renumbers specifically 1, 2, 3, 4, 5... etc
    That renumbering for each post_id# would then send an update to the SQL in a field that is provided called order which would take those values.
    Then 2 recordsets (one odd, one even) load not the post_id but the order# and all the relevant information (in this case a featured image) and output on the screen two columns of pictures that are in correct order based on whatever category is loaded.

    Thanks

    PS I have everything working that can do that, except for the one part that is most important, sending the reordered numbers that I have created to a field in SQL while within a Loop
  2. In Topic: Using a function within a loop to update mysql database field

    Posted 29 Sep 2012

    View Poste_i_pi, on 28 September 2012 - 07:30 PM, said:

    The @ symbol in SQL simply means "variable". There's no point looking up @rank, it would be like searching for $myVariable.

    If you're looking to order by the variable, you should be able to use the clause ORDER BY @rank. If that doesn't work, then you can wrap your statement in another SELECT and then use the ORDER BY, like this:
    SELECT *
    FROM (
      // Enter the other query here
    ) AS SubQuery
    ORDER BY rank
    
    


    Ah see and I didnt even realize that it could be done. Chalk this up to pure newbie oversight. Question, as people have pointed out, I am clearly very raw on what can be done in php vs sql. What would be the best books for me to order to continue to learn. I unfortunately right now have only DW6 Bible which helps to some extent but doesn't get into real programming, it really is more geared toward static site development.

    SO any recommendations on websites that have a good index of concepts and any books would be appreciated. And I really appreciate the assistance on using variables in the SQL code to re-sort my posts.
  3. In Topic: Using a function within a loop to update mysql database field

    Posted 28 Sep 2012

    order is basically a temporary field. I am not sure what the rank variable does but I will read into it.

    So this might be an issue of me not realizing there is something does it simpler (do to my lack of knowledge of all of the different options out there). The reason I went with this method was because I couldnt figure out how to get the posts to form a 2 wide column 3 rows tall with the 'featured_image' field based on their post_id without first making it so the left column was only odd, and the right column was even (you dont see that in the code because that is a separate file that I got to work). The problem became when I wanted to take that database and slice it to only see landscape category. Now the post_id couldnt be used because if the post_id # were 2,4,5,7,10,11 it would show as

    5 2
    7 4
    11 10

    which isn't my desired output. So going down the rabbit hole of how I started, I said well if I can create another variable that re-sorts those post_id # to turn it into 1,2,3,4,5,6 dependent on the category called upon just temporarily then I could have my recordset in the correct order. So I got the reordering to work fine, but the last step was I couldnt get it to update the field and thereby beable to recall the new sorted order.

    I hope that makes sense, I will read up on @rank because to be honest I've never heard of it before

    Sorry I'm an idiot, you mean why not use a variable in the query itself that would act like a rank.

    I couldn't figure how to get it to order by the variable instead of sorting by the post_id which is still outputting in the wrong order in my 2 column display given the above situation
  4. In Topic: Using a function within a loop to update mysql database field

    Posted 28 Sep 2012

    I have no dependence on either because I am new in both ways. I typically use dreamweaver only to fill out syntax not for WYSIWYG function. What I lack is syntax knowledge either way. I have only been quilting together what I can gather for about 2 weeks, before that I knew absolutely nothing about php. But your critique is accepted, and I will continue to try to get better for the remainder of my life beyond the past 2 weeks.

    %s was actually accidently put in there, the goal was to use the $row_RS_Odd['post_id']. Either way I know that isnt the issue because even when I tell it specifically to use post_id=3 which in this case I know is an ID number that should pass through, it still does not store the variable in the field.

    Any thoughts?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

tysons engineer hasn't added any friends yet.

Comments

tysons engineer has no profile comments yet. Why not say hello?