Welcome Guest, Not a member yet? Register   Sign In
Count problem
#1

[eluser]alexaaaaaaaaaa[/eluser]
Hi, i'm new with CI and i need this how to create a module for db to let the user to post only 2 projects / articles in one month.
here's what i have done so far
When the user posts a project/ article in the db it'll insert something like this
id user_id project_name description date
1 13 my project this is the desc. 1284982016
3 13 my project2 this is the desc2. 1284982365
5 13 my project3 this is the desc3. 1284982482

What i need is this how to insert a condition to check if the user has posted more than 2 projects in one month.
Regards,
Alexaaa

LE.
i have understand that it must be something like this
$d=date("Y-m-d");
$curent_month=mysql_fetch_array(mysql_query("SELECT MONTH('$d') as nr"));

$query="SELECT * from proiecte where (SELECT MONTH(data_postare_proiect)=$curent_month[nr] ) and id_user=$user_curent";

if mysql_num_rows(mysql_query($query))>2
redirect to another page.
#2

[eluser]techgnome[/eluser]
You'll want to include the year in that as well... other wise the projects posted in Sept of '08 will count against them too. And you may want to check for the num rows >= 2 ... if they have exactly 2, they will still be able to post using your current logic, bringing their total to 3.

-tg
#3

[eluser]alexaaaaaaaaaa[/eluser]
[quote author="techgnome" date="1285181499"]You'll want to include the year in that as well... other wise the projects posted in Sept of '08 will count against them too. And you may want to check for the num rows >= 2 ... if they have exactly 2, they will still be able to post using your current logic, bringing their total to 3.

-tg[/quote]

yeah your'r right but how can i translate that code into codeigniter

model:

function getprojects()
{
$this->db->from('projects');
$this->db->join('users', 'users.id = projects.programmer_id','left');

$this->db->select('projects.id,projects.project_name,projects.created,users.id as userid,projects.checkstamp,projects.provider_rated,projects.buyer_rated,projects.project_paid,projects.is_private,projects.flag');

$result = $this->db->get();

return $result;

}

controller
$this->outputData['myProjects'] = $this->skills_model->getprojects();

view:

if(isset($myProjects) and $myProjects->num_rows()>0)
{
foreach($myProjects->result() as $myProjects)
{
?>


<?php echo get_date($myProjects->created);?>

<?php } ?>




Theme © iAndrew 2016 - Forum software by © MyBB