Jump to content

Mahngiel

Newly Registered
  • Posts

    1,068
  • Joined

  • Last visited

Posts posted by Mahngiel

  1. I played with some conditional joins last night, and after a couple hours came up with the code below. 

     

    What's going on is I have several api resources that a row may belong to, and a supplemental api_id that relates to it.  Based on the value of the api_resource, I am joining the appropriate table.  Being new using conditionals in MySQL, I would like to know if there is a better way to accomplish this.

     

    SELECT t.id, t.name,
    CASE t.api_resource
        WHEN "x" THEN x.title
        WHEN "y" THEN y.title
    END as title,
    CASE t.api_resource
        WHEN "x" THEN x.genre
        WHEN "y" THEN y.genre
    END as genre
    
    FROM `files` t
    LEFT JOIN `file_x` x ON (t.api_resource = "x" AND t.api_id = x.id)
    LEFT JOIN `file_y` y ON (t.api_resource = "y" AND t.api_id = y.id)
    
    WHERE t.api_id != 0
    ORDER BY t.date DESC
    

     

    The resulting object:

    Object (
    [id] => 1
    [name] => Some name
    [title] => Title of api item
    [genre] => Genre of api item
    )

     

     

    Thanks.

  2.    if(!$ses_user && !$ses_pass){
          echo "You need to be logged in to view this page.";
       }
    

    (i hope you're encrypting your sessions.)

     

    an echo alone is not suffice for a security measure at all.  You could use a die() or a header() to a bolo page instead.

  3. probably a path problem. open up the Source and try to follow the link to your CSS. if a) there is no link, you now it's not included.  if b) the link 404's you know it's a path issue. 

     

    Tip:  link your CSS from the http path and not relative path.  Your last post said you were using codeigniter, so go example.com/application/views/style.css

  4. It makes more sense if you were working with a longer path.

    yes, but / is root is root is root. it doesn't matter if you're 15 levels deep, / is le whole enchilada!

     

    I add to the current theme, I once truncated the user table from the live environment.  :o :o

  5. It was not meant to offend you, simply to show the OP that it's harder than that because the structure of _FILES changes when you upload multiple files.

     

    @Ignace

    No offense taken.  You were correct in pointing out my post was half-assed

     

     

    @ Spertuit

    Dude, listen, if you're going to apply the same exact steps to more than one object, you should really think about loops.  ignace showed you how the foreach() looks, and i suggest u give it a whack.

  6. Or this, can someone lead me in the right direction for the code I should be using?

     

    The code you should be using is code that satisfies your requirements.

     

    add a checklogin code to a registration page  ...

    someone can add details into a database...

    checks if they are looged in.

     

    Based on your code examples, I suppose you mean a login form and you seem to have general idea.  Do you have any specific problems?

     

    BTW, I added some content to my signature.

  7. /me <3 SimCity!

     

    I've played the series for many, many years.  There are a plethora of Sim* games that they put out which weren't worth a damn, IMO, but SimCity has always been enjoyable for me.  I'd def grab a copy.

×
×
  • 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.