Jump to content

cmgmyr

Members
  • Posts

    1,278
  • Joined

  • Last visited

    Never

Posts posted by cmgmyr

  1. I have a mail table:

    CREATE TABLE `mail` (
      `mid` int(11) NOT NULL auto_increment,
      `parentid` int(11) NOT NULL default '0',
      `u_to` int(11) NOT NULL default '0',
      `u_from` int(11) NOT NULL default '0',
      `subject` varchar(100) NOT NULL default '',
      `message` text NOT NULL,
      `status` tinyint(1) NOT NULL default '0',
      `status2` tinyint(1) NOT NULL default '1',
      `date_sent` datetime NOT NULL default '0000-00-00 00:00:00',
      PRIMARY KEY  (`mid`)
    ) ENGINE=MyISAM;
    
    INSERT INTO `mail` (`mid`, `parentid`, `u_to`, `u_from`, `subject`, `message`, `status`, `status2`, `date_sent`) 
    VALUES (1, 0, 1, 306, 'Hi!', 'This is the first message', 1, 1, '2007-08-10 00:11:44'),
    (2, 1, 306, 1, '', 'This is the second', 1, 1, '2007-08-10 00:12:06'),
    (3, 2, 1, 306, '', 'This is the third', 1, 1, '2007-08-10 00:12:35');
    

     

    status is for the u_to, status2 is for u_from

    the status codes are 0=unread, 1=read, 2=deleted

     

    What I want to do is make a query that if one user deleted a message, the other user can still view it (if they didn't delete it). So in the exampe above both users read the thread. if you change status on mid #1 to '2' user number 1 shouldn't see it. User #306 should still be able to see it. How would I create this query?

     

    I have this so far:

    SELECT * FROM `mail` WHERE (u_to = $userid OR u_from = $userid) AND status != 2 AND parentid = 0 ORDER BY date_sent DESC

    but this doesn't show the message to the opposite user that deleted it.

     

    Please let me know if you need any more info.

    Thanks!

  2. I have this script:

    <?php
    $table = "<table border=1>\n";
    
    $sql = "SELECT id FROM categories LIMIT 1";
    $result = $db->query($sql);
    while($row = $db->fetch($result)){
    	$id = $row['id'];
    $table .= "
    <tr>
    <td>$id</td>
    <td>".$catalog->crumbs_category2($id)."</td>
    </tr>
    ";
    }
    
    $table .= "</table>";
    echo $table;
    ?>

     

    <?php
    function crumbs_category2($cat_id, $level=0) {  
    	global $db;
    	$sql = "SELECT parentid, name FROM categories WHERE id = $cat_id";
    	$result = $db->query($sql);
    	list ($p, $n) = $db->fetchRow($result);
    
    	if ($p != '0') $this->crumbs_category2($p, $level+1);
    	echo ($p == '0') ? "$n " : "- $n ";   
    }
    ?>

     

    and it outputs this:

    Fashion Jewelry <table border=1>

    <tr>

    <td>1</td>

    <td></td>

    </tr>

    </table>

     

    Why is this data not printing in the table?

     

    Thanks!

  3. Well you should really have a table for users, jobs, job_users, and files

     

    users

    -----

    userid

    name

    phone

    email

    ect...

     

    jobs

    -----

    job_id

    name

    ect...

     

    job_users (This is to give users access to certain jobs)

    -----

    ju_id

    userid

    job_id

    ect...

     

    files

    -----

    file_id

    job_id

    name

    file

    type

    ect...

     

    hope that sends you in the right direction

  4. Well I have a few takes on this, hopefully it will help you out.

     

    1. What I usually do if I have control over what the users are uploading (say .jpg's only) I set up a directory that they upload to and I rename the file to a random 16 char file name (so pretty much you can have a lot of them without worrying about if there are 2 files with the same name...even though you should still check.) Then I just store that file name in the database. This means that the database carries very little data.

     

    2. If I have no control over what they are uploading (different files types) I've used a blob in the database and a varchar to store the file type. Then when they call you download it, the file type goes in the header, and you print the blob (short version). This is good so that you don't need to worry about what they upload, but if you do this your database is going to get VERY large quickly, which this would be true for you because they would be uploading very large files.

     

    I think that you should go with #2, but there is no reason to have more then 1 table to hold this data. You can just make a column for "project_type" to hold if it's a job, img, etc...

     

    Hope this helps you out!

  5. try this:

    <?php
    function crumbs($id, $level=0) {  
    	$sql = "SELECT parentid, name FROM cats WHERE id = $id";
    	$result = mysql_query($sql);
    	list ($p, $n) = mysql_fetch_row($result);
    
    	if ($p != '0') crumbs($p, $level+1);
    	echo ($p == '0') ? "$n " : "» $n ";   
    }
    ?>

     

    hope that helps

  6. well as everyone said before the colors are bad. I don't want to stay on a page very long if it looks like someone took a dump on my screen.

     

    You also need content. No one wants to go to a site and be the first to post things. Make a few dumby accounts for yourself and go around the internet and find content for your site and submit it with those accounts (so it looks like more then just you (the admin) is posting things). Once you have good content then the people will come back.

  7. hmm that second return did the trick. Thanks! Here is the updated code.

     

    <?php
    function getChildMess($mid, $userid, $x=0){
    	global $db;
    	$new_sql = "SELECT * FROM mail2 WHERE (`to` = $userid OR `from` = $userid) AND `status` != 2 AND `parentid` = $mid LIMIT 1";
    	if($db->numRowsQ($new_sql) > 0){
    		$new_result = $db->query($new_sql);
    		while($new = $db->fetch($new_result)){
    			$new = $this->cleanArray($new);
    
    			$status = $new['status'];
    			$date = $new['date_sent'];
    			$mid = $new['mid'];
    			$message = $this->shortDesc($new['message'], 50);
    		}
    		$x++;
    		return $this->getChildMess($mid, $userid, $x);
    	}else{
    		if($x > 0){
    			$new_sql = "SELECT * FROM mail2 WHERE (`to` = $userid OR `from` = $userid) AND `status` != 2 AND `mid` = $mid LIMIT 1";
    			if($db->numRowsQ($new_sql) > 0){
    				$new_result = $db->query($new_sql);
    				while($new = $db->fetch($new_result)){
    					$new = $this->cleanArray($new);
    
    					$status = $new['status'];
    					$date = $new['date_sent'];
    					$message = $this->shortDesc($new['message'], 50);
    
    					return array("status" => $status, "date" => $date, "message" => $message);
    				}
    			}
    		}
    	}		
    }
    ?>

  8. at the very bottom of the script you will see

    return array("status" => $status, "date" => $date, "message" => $message);

     

    This repeats the function if there is another newer message

    $this->getChildMess($mid, $userid, $x);

    The $x is only there to see if there is more then 1 newer message...if there isn't it will just take the older (parent) information (not shown)/

     

    Thanks

  9. @akitchin: I have 2 accounts through guru, one for a pro and one for an employer. Besides that one story I shared I've done pretty well on guru as an employer (I usually get flash stuff done through there), as a pro I've done very well. It's pretty much how I got my start. There has been a few not so good projects that have come my way, but I got through them. I haven't spent a lot of time on there recently because my really good clients want more of me now and I no longer need to look for projects or time fillers. Right now I have a ranking of 123 in the Website Design / Website Marketing category. But this used to be under 100 less then 6 months ago when I was on there alot. I would recommend guru to people who are starting out that need to get stuff in their portfolio fast. Plus you can actually get paid decently on there as opposed to scriptlance.com type places where people only want to pay $150 for myspace. Plus on that site you need to pay to bid if you get the project or not...not cool.

     

    @ober: I'd be up for something like that

  10. Why is this function not returning my array? When I print it out within the function it works fine.

     

    <?php
    function getChildMess($mid, $userid, $x=0){
    	global $db, $bug;
    	//echo "mid: $mid, userid: $userid, x: $x <br />";
    	$new_sql = "SELECT * FROM mail2 WHERE (`to` = $userid OR `from` = $userid) AND `status` != 2 AND `parentid` = $mid LIMIT 1";
    	if($db->numRowsQ($new_sql) > 0){
    		$new_result = $db->query($new_sql);
    		while($new = $db->fetch($new_result)){
    			$new = $this->cleanArray($new);
    
    			$status = $new['status'];
    			$date = $new['date_sent'];
    			$mid = $new['mid'];
    			$message = $this->shortDesc($new['message'], 50);
    		}
    		$x++;
    		$this->getChildMess($mid, $userid, $x);
    	}else{
    		if($x > 0){
    			$new_sql = "SELECT * FROM mail2 WHERE (`to` = $userid OR `from` = $userid) AND `status` != 2 AND `mid` = $mid LIMIT 1";
    			if($db->numRowsQ($new_sql) > 0){
    				$new_result = $db->query($new_sql);
    				while($new = $db->fetch($new_result)){
    					$new = $this->cleanArray($new);
    
    					$status = $new['status'];
    					$date = $new['date_sent'];
    					$message = $this->shortDesc($new['message'], 50);
    
    					return array("status" => $status, "date" => $date, "message" => $message);
    				}
    			}
    		}
    	}
    ?>

     

    ...and this doesn't print anything

    <?php 
    
    $new_array = $func->getChildMess(1, 1);
    
    echo "<pre>";
    print_r($new_array);
    echo "</pre>";
    
    ?>

     

    also...if there is an easier way to do this. please feel free to share. I'm trying to get the last message in a conversation.

     

    Thanks,

    -Chris

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