Results 1 to 5 of 5

Thread: Check DB - show message, or something else

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Check DB - show message, or something else

    ok so i have this code:

    PHP Code:
    <?php
         $sr_no
    =$sr_no+1;
         
    $sql="select * from member_friends a, journal b where b.journal_of = a.friend_id and a.member_id = $_SESSION[member_id] order by journal_id desc limit 0,8";
         
    $friend_res=mysql_query($sql);
         print 
    mysql_error();
         while(
    $data_set=mysql_fetch_array($friend_res))
         {
    ?>
    <tr bordercolor="#666666">
    <?php
         $name
    =$people->get_name($data_set["journal_of"]);
    ?>
    <td width="29%" height="23" align="left" bgcolor="D5E8FB" class='txt_label'>
      <div align="left"><a href='view_profile.php?member_id=<?=$data_set["journal_of"]?>'>
        <?=$name?>
      </a></div></td>
    <td width="28%" height="23" align="left" bgcolor="D5E8FB" class='txt_label'>
      
        <div align="left">
          <?=$data_set["journal_date"]?>
          <br>
          </div></td>
    <td width="43%" height="23" valign="center" bgcolor="D5E8FB" style="word-wrap:break-word">
    <span class="txt_label">
    <div align="left"><a href='view_journal.php?journal_id=<?=$data_set["journal_id"]?>'>
      <?=stripslashes($data_set["subject"])?>
    </a></div></td>
    </tr>
    <?php
           $sr_no
    =$sr_no+1;
    }
    ?>
    </table>
    <div align="center"><br>
        <br>
        <?php
        
    if($sr_no==1)
        {
    ?>
        <span class="txt_label style1">You do not have any bulletins yet.</span><br>
      <span class="blacktext10nb">
        Bulletins are messages from and to all your friends at once. You can use bulletins to alert your friends about a party, things for sale, job hunts, etc.
      <br>
      <br>
        </span>
        <?php
        
    }
    ?>
    and sometimes we may need that to be unavalible to the users. How do i have it ceck the db if there is anything in the field "message". If there is anything in it then it displays it. if not. it shows the code normaly.
    My usual boring signature: Something

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Check DB - show message, or something else

    umm. are there multiple records in the table? if you want to check if the table is empty, use mysql_num_rows() before you call mysql_fetch_array() with the loop. something like this:
    PHP Code:
    <?php
      $myquery 
    "SELECT * FROM blah WHERE blah=blah LIMIT 5";
      
    $query mysql_query($myquery);
      
    $num mysql_num_rows($query);
      if(
    $num 0){
        
    //found messages, display them
        
    while($results mysql_fetch_array($query)){
          echo 
    'record information';
        }
      }else{
        
    //result was empty, display the "no messages" message.
      
    }
    ?>
    was that what you wanted?
    Like Archer? Check out some Sterling Archer quotes.

  3. #3

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Check DB - show message, or something else

    i dont think that is what i am looking for. i started adding it to my code and it did not look right.

    I want it to:
    1. Check "bulletin_message".
    --(this is diffrent from where the bulltetins are stored)
    2. If there is anything in the column "message" then display the message not the code that i put above
    3. if thereis nothing in the column, then display the code above.
    My usual boring signature: Something

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Check DB - show message, or something else

    then you can just do this:
    PHP Code:
    <?php
      $impbulletin_sql 
    "SELECT bulletin_message FROM table";
      
    $impbulletin_query mysql_query($impbulletin_sql);
      
    $impbulletin mysql_fetch_array($impbulletin_query);
      if(isset(
    $impbulletin['bulletin_message']) && $impbulletin['bulletin_message'] != ""){
        
    //print your important message
      
    }else{
        
    //no important bulletin found, print the rest of the normal messages
        
    $sql "select * from blah where blah";
        
    //you do the rest. normal code goes here
      
    }
    ?>
    alternatively, I would say it'd be rather annoying as a user of your site to not be able to view any "normal" bulletin messages when an "important" bulletin was displayed.. so, I would suggest you just made the important bulletin display at the top if there is one, while also displaying the other less important/normal messages just underneath it. you could tack on a "important" or make the text size for the important message bigger, or whatever.
    Like Archer? Check out some Sterling Archer quotes.

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Check DB - show message, or something else

    well this is for an onine community that i am working on. Some guy bought the script and it looks too much like myspace so we are changing it. And sometimes we have errors with the bulletin system and we need to close it. Insted of going into the code and changing it to what we want. we want to have an option in the admin section to tunr it on/off.

    Thanks for the code!
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width