Exemple #1
0
function buy_project($cart_id, $number)
{
    global $db;
    $user_id = $_SESSION['user'];
    $query = "SELECT * FROM cart WHERE id = '{$cart_id}';";
    $result = $db->query($query);
    $project_id = $result->fetch_assoc()['project_id'];
    $query = "DELETE FROM `cart` WHERE id = '{$cart_id}'";
    $result = $db->query($query);
    while ($number > 0) {
        $query = "SELECT id FROM project_links WHERE project_id = '{$project_id}' AND user_id = 0  LIMIT 1";
        $project_link_id = $db->query($query);
        $project_link_id = $project_link_id->fetch_assoc()['id'];
        $query = "UPDATE  `project_links` set user_id = '{$user_id}', sold = 1 Where id= '{$project_link_id}';";
        $result = $db->query($query);
        $number--;
    }
    return array("success", get_cart_number(), get_project_count($project_id), $project_id);
}
        <?php 
if ($_GET['assign'] == "done") {
    ?>
        <div style="color:#006600"><strong> Thanks for assigning images to Project.</strong></div>
        <?php 
} else {
    if ($_GET['assign'] == "no") {
        ?>
<div style="color:#FF0000"><strong>No Image Available.</strong></div>
        <?php 
    }
}
?>
        
       <?php 
$project_count = get_project_count();
$cls = 'textdiv';
if (get_project_count > 0) {
    $cls = '';
}
?>
        
        <form name="checkconform" action="" method="post" >
        <div><select name="your_project" class="form-control mselect" id="project"><?php 
selectbox_project();
?>
<option value="other">Other</option></select></div>
        <div class="<?php 
echo $cls;
?>
 topmargin" id="hidtext" ><input id="myproject" type="text" name="myproject" value="" <?php