Testing for emtpy result.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    Testing for emtpy result.

    Hi there,

    I'm working with a bit of a messy query but I'm not looking for tips
    on improving it (it's been a headache enough, haha).

    Basically, my site posts articles written by multiple authors. In the
    past we'd associate these articles with a user_id referring to the
    "Multiple" author, but now writers want their own writing within an
    article to be linked with them.

    This led to me splitting the article table in two: we have
    review_index which has all the generic/global data for the article
    (band name, record label, etc), and review_pages which has a (non-
    unique) field review_id which links to the id row in the review_index
    table. With me so far?

    The form I wrote for admins to post multiple author reviews works like
    this:

    - asks them for global variables and inserts them
    - asks them to add a review and select username for an author
    - upon submitting this, offers them to post another (still associated
    with the original globals) or lets them close the job.

    It's done in this way because in order to associate the review_id with
    the id field, I have to KNOW what the id field in the review_index is
    going to be. I can't just +1 to the most recent one, since this'll
    cause issues if we delete reviews etc.

    So what this means is, when a user clicks onto an article while we're
    in the process of posting it, they may load a page with all the
    globals in place, but none of the actual content. I'm trying to echo a
    simple "Please reload the page in a few minutes" message, but can't
    get a working result. I've tried variations on:

    if ($review_text = null) {
    echo "come back soon!";
    }

    if (empty($review_ text)) {
    echo "come back soon!";
    }

    if (!$query_result ) {
    echo "come back soon!";
    }

    but none of these display. Is there a solution here? It's a trivial
    issue really since it's essentially catering to people who click on an
    article within a 1 minute or so period, but still.

    Matt

  • Matt

    #2
    Re: Testing for emtpy result.

    dammit, typo in the subject. Should be 'empty'!

    Comment

    • Rik

      #3
      Re: Testing for emtpy result.

      On Wed, 06 Jun 2007 19:46:40 +0200, Matt <guitarromantic @gmail.comwrote :
      Hi there,
      >
      I'm working with a bit of a messy query but I'm not looking for tips
      on improving it (it's been a headache enough, haha).
      >
      Basically, my site posts articles written by multiple authors. In the
      past we'd associate these articles with a user_id referring to the
      "Multiple" author, but now writers want their own writing within an
      article to be linked with them.
      >
      This led to me splitting the article table in two: we have
      review_index which has all the generic/global data for the article
      (band name, record label, etc), and review_pages which has a (non-
      unique) field review_id which links to the id row in the review_index
      table. With me so far?
      Not really, no.

      Are reviews the same as articles?

      The form I wrote for admins to post multiple author reviews works like
      this:
      >
      - asks them for global variables and inserts them
      - asks them to add a review and select username for an author
      - upon submitting this, offers them to post another (still associated
      with the original globals) or lets them close the job.
      Or you could have a usual form:

      Review for:
      - (radio) existing data (automatically selects last entered 'article')
      - (radio) new data -formfields for data required for this
      Review:
      - content
      - author

      So, you still will save an article with the content provided to you by a
      particular author at the same time (well, fractions of a second apart).

      Possibly you could add a radio list/selectbox at the bottom about what
      they want to do after adding it:
      a: add another review by another author for this article.
      b: add another review for another article.
      c: stop adding stuff at all
      It's done in this way because in order to associate the review_id with
      the id field, I have to KNOW what the id field in the review_index is
      going to be. I can't just +1 to the most recent one, since this'll
      cause issues if we delete reviews etc.
      >
      So what this means is, when a user clicks onto an article while we're
      in the process of posting it, they may load a page with all the
      globals in place, but none of the actual content. I'm trying to echo a
      simple "Please reload the page in a few minutes" message, but can't
      get a working result. I've tried variations on:
      >
      if ($review_text = null) {
      echo "come back soon!";
      }
      >
      if (empty($review_ text)) {
      echo "come back soon!";
      }
      >
      if (!$query_result ) {
      echo "come back soon!";
      }
      >
      but none of these display. Is there a solution here? It's a trivial
      issue really since it's essentially catering to people who click on an
      article within a 1 minute or so period, but still.
      Normally, when adding something requires several steps, one could also add
      a 'publish' boolean field, which is checked on displaying
      lists/navigation/articles etc. Set to 0 for the duration, set to 1 if
      finished, don't display anything that has 0 as a publish value.


      --
      Rik Wasmus

      Comment

      • Matt

        #4
        Re: Testing for emtpy result.

        On Jun 6, 7:12 pm, Rik <luiheidsgoe... @hotmail.comwro te:
        Normally, when adding something requires several steps, one could also add
        a 'publish' boolean field, which is checked on displaying
        lists/navigation/articles etc. Set to 0 for the duration, set to 1 if
        finished, don't display anything that has 0 as a publish value.
        >
        --
        Rik Wasmus
        This sounds like the simplest solution (ashamed it didn't occur to
        me), especially since I already have a 'type' field I could adapt for
        this purpose. Thank you.

        (for the record, yeah, a review = article. Should have been more
        clear, apologies)


        Comment

        • Phil

          #5
          Re: Testing for emtpy result.

          Couldn't you use something like this?

          if (strlen(trim($r eview_text)) 0 ) // do something
          else echo "some message"



          Comment

          • Schraalhans Keukenmeester

            #6
            Re: Testing for emtpy result.

            At Wed, 06 Jun 2007 17:46:40 +0000, Matt let h(is|er) monkeys type:
            Hi there,
            >
            I'm working with a bit of a messy query but I'm not looking for tips
            on improving it (it's been a headache enough, haha).
            >
            >
            if ($review_text = null) {
            echo "come back soon!";
            }
            >
            $review_text = null isn't a test, but an assignment. Don't you mean == or
            ===?

            Is $review_text always really empty in your test? (what length has it
            got?)
            but none of these display. Is there a solution here? It's a trivial
            issue really since it's essentially catering to people who click on an
            article within a 1 minute or so period, but still.
            >
            Matt
            --
            Schraalhans Keukenmeester - schraalhans@the .Spamtrapexampl e.nl
            [Remove the lowercase part of Spamtrap to send me a message]

            "strcmp('apples ','oranges') < 0"

            Comment

            Working...