unemployment
-
Posts
746 -
Joined
-
Last visited
Posts posted by unemployment
-
-
Well yes, the points for friends would be dynamic not necessarily 20 points. So the more points my friends earn, over time, not at the point of befriending, the more points I will earn. So this will be a completely live system. That's where the complexity builds in. I'm not sure how to work that out.
-
Essential here is a sample system.
Points gain for tasks done -
Personal Profile completion = 200 points
Created or joined a verified company profile = 200 points
Having a company video = 50 points
Blog Post = 50 Points
Number of friends = 20 points each
Number of votes submitted = 5 points each
Number of fans your company receives = 10 points each
Twitter shares for blog post = 1 points
Facebook shares for blog post = 1 points
Google plus 1 for blog post = 1 points
It would kind of cool if this could be dynamic... If one user has 20500 point and one has 100 points and I become friends with both of themI don't want to be given the same 20 point gain. I should be given more points for the person that has more points because they are a more valuable contact.
Any thoughts on how to be code this out?
Some of this will be static and some of it will be dynamic.
-
I'm making a game where you earn points and lose points based on the actions that you take and the actions that your opponents take. What's the best way to create this system. Should I use mysql to store all the data and if so, should I set up the actions in a seperate table or should I just join the actions from all of my other tables. I'm not quite sure what the best method is.
-
looks like I made another dumb mistake. Good call out. Thanks.
-
function fetch_blog_post_mini_profile_by_pid($pid)
{
$pid = (int)$pid;
$sql = "SELECT `postcontent` FROM `blog_posts` WHERE `post_id` = '${pid}'";
$result = mysql_query($sql);
return mysql_fetch_assoc($result);
}
-
I'm storing a blog post in MySQL and it has html entities in it. I tried doing...
$info = fetch_blog_post_mini_profile_by_pid($_GET['pid']);
$info = substr($info, 0, 200);
to get a summary of the content, but it says it's not a string. What am I missing?
-
Yeah, you're right. Those commas can kill you. I guess I wasn't looking in the right spot.
-
I'm trying to get the data for a single user, but I have a loop error and I don't understand why. Can someone please clarify where I went wrong?
function fetch_user_info_mini_profile_by_uid($uid){ $uid = (int)$uid; $sql = "SELECT '${uid}' AS `uid`, `username` AS username, `firstname`, `lastname`, `accounttype`, `country`, `state`, `city`, FROM `users` WHERE `id` = '${uid}'"; $query = mysql_query($sql); $profile = array(); while (($row = mysql_fetch_assoc($query)) !== false) { $profile = array( 'uid' => $row['uid'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'username' => $row['username'], 'accounttype' => ($row['accounttype'] == '1') ? 'Entreprenuer' : 'Investor', 'country' => $row['country'], 'state' => $row['state'], 'city' => $row['city'], 'display_name' => ucwords("${row['firstname']} ${row['lastname']}"), ); } $profile['avatar'] = getUserAvatar($row['username']); return $profile; }
-
This code is working for me but it just looks sloppy.
Can this be written nicer?
echo ' <a href="/u/'.$user_info['username'].'"> <img src="', getUserAvatar($user_info['username']), "\" class=\"avatar navigation small f_left clear\" title=\"${user_info['display_name']}\" alt=\"${user_info['display_name']}\" /> <span>${user_info['display_name']}</span> <span class=\"tri\">▼</span> </a>";
-
why do you have id and company_id/user_id fields in tables 2 and 3 and why oh why did you name a field with a reserved word (time)?
Basicly what you want to do is pull it out the database without the grouping, and then run conditional formating against your "time" field that only shows actions from either table if it has been within a set period, and is not a duplicate of the last. There are a couple of ways of doing that in PHP, if that is what you are using. What are you using to display the results of the query and how comfortable are you with that language?
That said, you could possably pull it off using a CASE clause in the select statement if you are really heart set on having it done in the SQL.
I'd much rather prefer to do it in the sql. When I made tables I probably should have just labeled them all id and I didn't know time was a reserved word.... hmm the things you learn. I've never used a case statement and I'd have no idea where to start. I don't know how you can compare rows and time intervals. The reason why I'd rather do it in the sql is that my php is already set which I don't really want to touch. Plus getting the proper sql would be a little more efficient.
Can you give me a good example of how to use a case statement for this?
-
what you want to do is a formatting issue, not a query issue. could you post up your table structures please?
Tables 1 - actions
id, actiondescription
Table 2 - Company Actions
id, company_id, action_id, time, details
Table 3 - User Actions
id, user_id, action_id, time, details
The only data I need grouped by interval should be the user and company actions. Everything else is fine.
-
I am in the process of creating a news feed. The news feed will say something like... You have just updated your profile picture. Every time a user updates their profile picture, a news feed row is added to the news feed.
The problem:
If a user uploads their picture three times in a row it will say...
You have just updated your profile picture.
You have just updated your profile picture.
You have just updated your profile picture.
Which looks terrible. I can adjust the group by to concatenate the similar rows into one row, but then if I ever update my profile picture again, even when I don't have repeated actions it will continue to group those actions into one row.
Solution I need:
If the actions above or below a give row are the same, then group them together into one row. If not don't group them.
What I probably need is a way to group actions over a time interval. If the same action occurs within 5 minutes of the first one, then group by.
Current Model:
You have just updated your profile picture.
You have just updated your profile picture.
You have just joined XYZ company.
You have just updated your profile picture.
You have just updated your profile picture.
New Result I Need:
You have just updated your profile picture.
You have just joined XYZ company.
You have just updated your profile picture.
Current Query:
SELECT
users.id,
users.firstname,
users.lastname,
users.username,
companies.companyid AS companyid,
companies.industry AS industry,
companies.stage AS stage,
companies.companytag AS companytag,
'' AS gender,
'' AS accounttype,
companies.country,
companies.state,
companies.city,
UNIX_TIMESTAMP(`company_actions`.`time`) AS `approve_date`,
'' AS FeedId,
companies.companyname AS FeedFirstName,
'' AS FeedLastName,
'' AS FeedUserName,
GROUP_CONCAT(actions.actionsdescription SEPARATOR '~') AS `action_id`,
GROUP_CONCAT(company_actions.details SEPARATOR '~') AS `details`
FROM users
INNER JOIN employees ON employees.userid = users.id AND users.accounttype IN (".implode(',',$user_types).")
INNER JOIN companies ON employees.companyid = companies.companyid
INNER JOIN company_actions ON company_actions.company_id = companies.companyid
INNER JOIN actions ON company_actions.action_id = actions.id
WHERE company_actions.time < '${time}'
GROUP BY
users.id,
users.firstname,
users.lastname,
users.username,
companyid,
industry,
stage,
companytag,
gender,
accounttype,
companies.country,
companies.state,
companies.city,
approve_date,
FeedId,
FeedFirstName,
FeedLastName,
FeedUserName
-
Thank you... That worked
-
How can I make $10.58 round up to $11?
Right now my code makes $10.58 into $1,058
if (preg_match_all('#([0-9]+)#', $_POST['capitalrequestedas'], $matches) > 0) { $capitalrequested = implode($matches[1]); } else { $capitalrequested = 0; }
-
Here is the scenario….
I need to add in….
AND user_actions.action_id != 15
AND user_actions.action_id != 24
But when I do that it removes my welcome message / or my welcome back message and I need that to only occur for when friend.id != {$uid}
SELECT
users.id,
users.firstname,
users.lastname,
users.username,
'' AS companyid,
'' AS industry,
'' AS stage,
'' AS companytag,
friends.gender,
users.accounttype,
users.country,
users.state,
users.city,
UNIX_TIMESTAMP(`user_actions`.`time`) AS `approve_date`,
friends.id AS FeedId,
friends.firstname AS FeedFirstName,
friends.lastname AS FeedLastName,
friends.username AS FeedUserName,
GROUP_CONCAT(actions.actionsdescription SEPARATOR '~') AS `action_id`,
GROUP_CONCAT(user_actions.details SEPARATOR '~') AS `details`
FROM users
INNER JOIN partners ON partners.user_id = users.id AND partners.approved = 1
INNER JOIN users friends ON partners.friend_id = friends.id
INNER JOIN user_actions ON user_actions.user_id = friends.id
INNER JOIN actions ON user_actions.action_id = actions.id
WHERE users.id = ${uid}
AND `user_actions`.`time` < '${time}'
GROUP BY
users.id,
users.firstname,
users.lastname,
users.username,
companyid,
industry,
stage,
companytag,
friends.gender,
users.accounttype,
users.country,
users.state,
users.city,
approve_date,
FeedId,
FeedFirstName,
FeedLastName,
FeedUserName
-
I need to redirect mysite/join to mysite/join?2e957e
My current rewrite condition is failing
RewriteRule ^join.php/?$ join?2e957e [NC,L]
-
Very nice logic. I wouldn't have thought to use a CASE
-
I have updated my inputs with...
<input id="occupation_<?php echo $i; ?>" type="text" name="occupation_<?php echo $i; ?>" value="<?php echo $occupation['function']; ?>" /> <input type='hidden' name='occupation[]' value='<?php echo $occupation['companyid']; ?>' />
My employees table is setup with...
user_id
company_id
occupation
-
How can I use php to update a dynamic amount of input fields and tell mysql which ones to update respectively? Essentially I have a list of occupations and if someone wants to update one of them I don't know how to tell php which one they've changed in a dynamic way.
<?php if(!empty($occupations)) { ?> <h3 id="job_function">Job Functions</h3> <?php $i = 0; foreach($occupations as $occupation) { ?> <div class="formElement"> <div class="formFieldLabel "> <label for="occupation_<?php echo $i; ?>"><?php echo $occupation['companyname']; ?></label> </div> <div class="formField"> <input id="occupation_<?php echo $i; ?>" type="text" name="occupation_<?php echo $i; ?>" value="<?php echo $occupation['function']; ?>" /> </div> </div> <?php $i++; } } ?>
-
Here is one of my emails.
Delivered-To: jason@gmail.com
Received: by 10.204.57.134 with SMTP id c6cs22321bkh;
Tue, 13 Sep 2011 07:23:32 -0700 (PDT)
Received: by 10.101.168.12 with SMTP id v12mr3751263ano.48.1315923810914;
Tue, 13 Sep 2011 07:23:30 -0700 (PDT)
Return-Path: <contact@big.com>
Received: from big.com (big.com [173.0.59.100])
by mx.google.com with ESMTP id c19si889696anj.173.2011.09.13.07.23.29;
Tue, 13 Sep 2011 07:23:29 -0700 (PDT)
Received-SPF: pass (google.com: domain of contact@big.com designates 173.0.59.100 as permitted sender) client-ip=173.0.59.100;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of contact@big.com designates 173.0.59.100 as permitted sender) smtp.mail=contact@big.com; dkim=neutral (body hash did not verify) header.i=@big.com
Received: by big.com (Postfix, from userid 33)
id 1BDCE2F4041A; Tue, 13 Sep 2011 10:23:20 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=big.com; s=mail;
t=1315923800; bh=ysNGlrscqmqCPbqxJlWWHLaW3SU6MgDVQCze+cevPS4=;
h=To:Subject:Message-ID:Date:MIME-Version:Sender:From:Reply-To:
Content-Type;
b=PDPCRvKGQRP3LeeDNhZQwbX6aMXOZEyqRXV1E+kuDDq05NYRIrmJCcQRhwEIaSosh
yoZ0pF5wtrXjgY1KA0hgee7qzSVDhweguBfOydn1qE6nsL1pqCQgsHmtvu9dwPGw9z
uUEHM9bg5DwiG0RT5KLYf4oZTJmJpc8n2oyK26/I=
To: jason@gmail.com
Subject: Closed Beta Invitation from Jason Gordon
Message-ID: <87847890-050333@big.com>
Date: Tue, 13 Sep 2011 10:38:17 -0400
MIME-Version: 1.0
X-Mailer: PHP-5.3.8
X-Sender: "big" <contact@big.com>
X-Priority: 3
Organization: big
Errors-To: contact@big.com
Sender: contact@big.com
From: "big" <contact@big.com>
Reply-To: "big" <contact@big.com>
Content-Type: multipart/alternative; boundary=87847890
--48673093
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<a href="http://big.com/u/jasonGordon?utm_source=beta_invite&utm_medium=email&utm_content=referer_name&utm_campaign=join_beta" alt="Jason Gordon's profile" title="Jason Gordon's profile">Jason Gordon</a> invited you to join the newest community of entreprenuers and investors, big.
Why participate in our closed beta? Here you will be able to find, research and connect with entrepreneurs or investor so much easier than ever before.
You will be one of the first people to ever lay eyes on our exclusive software!
Sign up by clicking <a href="http://big.com/join?9b782e=&key=7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf&utm_source=beta_invite&utm_medium=email&utm_content=sign_up&utm_campaign=join_beta" title="big Beta Referral">here</a>
If the link does not work, go to <a href="http://big.com" title="big">big.com</a>, click "Join big" and enter your closed beta access key.
Your closed beta access key is: 7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf
Please leave us feedback so that we can improve our software.
big Team
--48673093
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Closed Beta Invitation</title>
</head>
<body>
<table width="500px" cellspacing="0" cellpadding="13" style="border: 1px solid #e7e7e7;">
<tr>
<td>
<table cellspacing="0" cellpadding="5" bgcolor="#ffffff" width="480px" style="border: 1px solid #999999;">
<tr>
<td bgcolor="#489fcc" cellspacing="15" style="border-bottom: 1px solid #999999; border-top: 0; border-left: 0; border-right: 0; font-family: verdana; letter-spacing: 1px; font-weight: bold; color: white;" width="480px">
big
</td>
</tr>
<tr>
<td>
<table style="line-height: 26px; font-family: arial; font-size: 13px;" width="100%" cellspacing="10" cellpadding="0">
<tr>
<td width="100%">
<table style="line-height: 26px; text-align: justify;" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<a href="http://big.com/u/jasonGordon?utm_source=beta_invite&utm_medium=email&utm_content=referer_name&utm_campaign=join_beta" alt="Jason Gordon's profile" title="Jason Gordon's profile">Jason Gordon</a> invited you to join the newest community of entreprenuers and investors, big.
Why participate in our closed beta? Here you will be able to find, research and connect with entrepreneurs or investor so much easier than ever before.
You will be one of the first people to ever lay eyes on our exclusive software!
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" width="100%">
<table style="border-top: 1px solid #b8b8b8; border-bottom: 1px solid #b8b8b8;" width="100%" cellpadding="0" cellspacing="5">
<tr>
<td width="100%" align="center">
Sign up by clicking <a href="http://big.com/join?9b782e=&key=7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf&utm_source=beta_invite&utm_medium=email&utm_content=sign_up&utm_campaign=join_beta" title="big Beta Referral">here</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" style="text-align: justify;">
If the link does not work, go to <a href="http://big.com" title="big">big.com</a>, click "Join big" and enter your closed beta access key.
Your closed beta access key is:
</td>
</tr>
<tr>
<td align="center" width="100%">
<table bgcolor="#e6e6e6" style="border: 1px solid #b8b8b8;" width="100%" cellpadding="0" cellspacing="5">
<tr>
<td width="100%" align="center">
7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%">
Please leave us feedback so that we can improve our software.
</td>
</tr><tr>
<td width="100%">
big Team
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
--48673093--
My headers function is...
function mail_header ($type, $random_hash) { $type = (int)$type; if ($type === 0) { $boundary = $random_hash; $x_mailer = phpversion(); $time_stamp = date("r"); $headers = 'Message-ID: <'.$boundary.'-050333@big.com>' . "\r\n"; $headers .= 'Date: ' . $time_stamp . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'X-Mailer: PHP-' . $x_mailer . "\r\n"; $headers .= 'X-Sender: "big" <contact@big.com>' . "\r\n"; $headers .= 'X-Priority: 3' . "\r\n"; $headers .= 'Organization: big' . "\r\n"; $headers .= 'Errors-To: contact@big.com' . "\r\n"; $headers .= 'Sender: contact@big.com' . "\r\n"; $headers .= 'From: "big" <contact@big.com>' . "\r\n"; $headers .= 'Reply-To: "big" <contact@big.com>' . "\r\n"; $headers .= 'Return-Path: "big" <contact@big.com>' . "\r\n"; $headers .= 'Content-Type: multipart/alternative; boundary=' . $boundary . "\r\n"; } return $headers; }
-
I decide to go with unlink("{$GLOBALS['path']}/img/avatars/companies/${cid}.png");
-
What is the full path to the file?
/assets/img/avatars/users/jasongordon.png
or
/home/www-data/big.com/assets/img/avatars/users/jasongordon.png
On my server it's /home/www-data/big.com/assets/img/avatars/users/jasongordon.png
-
After a user on my site deletes their account I want their profile picture to be deleted from my images folder. I was testing the unlink function on my index.php file and it is failing.
Here is the error: Warning: unlink(/assets/img/avatars/users/jasongordon.png): No such file or directory in /home/www-data/big.com/index.php on line 86
My code was just: unlink('/assets/img/avatars/users/jasongordon.png');
I'm not sure why this fails because my file does exist.
-
Can I please have this approved?
Rating System
in PHP Coding Help
Posted
Hmm that really sucks. I see your point.