name database : db_shop
table_user : uid_user, name_user
table_shop : uid_user, date
table_question :uid_user, date

Help me....
if user wants to accessing to page question, script php will check formerly will what him buy or not yet in certain, has user answered what not yet in certain? if buy so page question can be accessinged, but if user not yet buy so page question can not be accessinged, if user has bought and answer question in same so yard question a while ago will not be accessinged. yard question appear one month once

name database : db_shop
table_user : uid_user, name_user
table_shop : uid_user, date
table_question :uid_user, date

Help me....
if user wants to accessing to page question, script php will check formerly will what him buy or not yet in certain, has user answered what not yet in certain? if buy so page question can be accessinged, but if user not yet buy so page question can not be accessinged, if user has bought and answer question in same so yard question a while ago will not be accessinged. yard question appear one month once

Make sure you datetypes are stored from php's time() and converted to (my)sql when saved. That way you can use sql to compare the dates and return values, faster and more portable than using php.

Read about mysql time functions and comparisons here: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

Hey.

Just to check if I understood that correctly:

  1. You want to allow your users to answer a question form about products they have already bought.
  2. And you want them to be able to edit their answers once ever month? (I'm fairly sure I got this part wrong xD)

Well, the first part is easy. Just a basic query to check if a record in the child part of a 1:N (parent:child) relationship exists:

<?php
// Connect to database
$dbLink = new mysqli("host", "user", "pwd", "dbName");
if(mysql_connect_errno()) {
  die("Failed to connect to db: ". mysql_connect_error());
}

// Get UserID and ShopID.
// I'm just going to use the GET protocol. You replace this with
// whatever fits the situation.
$userID = intval(@$_GET['userID']);
$shopID = intval(@$_GET['shopID']);
if($userID == 0 or $shopID == 0) {
  die("Invalid user or shop ID");
}

// Execute a SQL query to test if the user has bought the "shop".
// (Assuming a language barrier there. Product makes more sense.)
$sql = "SELECT `date` FROM `table_shop`
        WHERE `uid_shop` = {$shopID} AND `uid_user` = {$userID}";
$result = $dbLink->sql($sql);

if($result && $result->num_rows > 0)
{
    // Show the answer form,
    // or process the answer form,
    // or whatever else you want done for the bought "shop".
}
else
{
    echo "Sorry, you haven't bought this 'shop' yet.";
}
?>

I don't actually get the other part so I won't attempt to solve that one yet. Please try to explain that part a little better.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.