Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hey coders...I'm a novice at web development and I have my project to complete by tuesday, so all the help I can get will be much appreciated!!
The code below is of fetched data from a servicepost table, the post 'bid' is meant to enable the user to bid for the servicepost, store the bid in bid table and also notify the user who posted it that there is a bid (notification in the second code) and then the user shouldn't be able to bid for the same servicepost again...
XML
<pre lang="PHP">
<form id="postbid" action="" method="post" data-inline="true" style="padding-right:2%">
<b><ul class="ui-bar-d"><em>Username:</em>&nbsp;<u><?php echo $request[$username] ?></u></ul><br>
<ul><em>I want a freelancer to complete:</em>&nbsp;<u><?php echo $request[$service_details] ?></u></ul>
<ul><em>To be completed by:</em>&nbsp;<u><?php echo $request[$duedate] ?></u><br></ul>
<ul><em>At a fee of Ksh.</em>&nbsp;<u><?php echo $request[$fee] ?></u><em><?php echo $request[$Negotiable] ?></em></ul>
</b>
<ul align="right">
  &lt;input type="submit" name="bid" id="bid" value="Make a Bid" data-mini="true" data-inline="true" onClick="POST"/>
</ul>&lt;/form><hr><br>
<?php
if (isset($_POST["bid"]))
     {
    //take care of injections
    $bid = mysqli_real_escape_string($link,$_POST['bid']);
    $biddate = date("Y-m-d, H:m:s");
// Insert data into mysql + LOGGED IN USER'S USERNAME TO BE INSERTED
     $sql = "INSERT INTO bids VALUES (NULL, '".$_SESSION['username']."', '".$bid."', '".$biddate."', NULL)";
    $result= $link ->query($sql) or die (mysqli_error($link));

// if successfully insert data into database, display message "Successful".
    if($result){
             echo "&lt;script>alert('Bid Posted!');&lt;/script>";
                }
    else {
echo "&lt;script type='text/javascript'>alert('bid failed!')&lt;/script>";
            }
    //$link->close();
    }
}
    ?>
</pre>


--Here is the notification dialog box...the client should also be able to accept a bid...notifying the bidder through a #viewbids div that their bid was accepted...

XML
<pre lang="PHP">
<!--POP UP FOR CLIENTS NOTICES-->

<div data-role="dialog" id="notifications" data-theme="c">
<div data-role="header"><h1>Notifications</h1></div>
    <div data-role="content" data-theme="b">

<div class="ui-body-c" id="counter" style="border-spacing:3%"><strong><span class="ui-li-count"><?php echo $bid ?></span>New Bids</strong></div>
    <?php
    if (!$link) {
die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT username, service, service_details, duedate FROM servicepost ";
$result = mysqli_query($link, $sql);

if (mysqli_num_rows($result) > 0) {
$i=0;
// output data of each row
while($row = mysqli_fetch_assoc($result))
{
      $username= $row['username'];
      $service= $row['service'];
      $service_details= $row['service_details'];
      $duedate= date('d-M-Y', strtotime($row['duedate']));
            }
        } else {
      echo "0 results";
}
?>
<div class="ui-field-contain" id="bid_details">
<p><em>Bid made by</em>&nbsp;<strong><a href="info.php#bidderinfo" data-ajax="false" data-rel="dialog"><?php echo $username?></a>&nbsp;</strong><em>at</em><strong><?php echo $biddate?></strong><br>
<em>For your</em>&nbsp;<strong><a href="info.php#requestinfo" data-ajax="false" data-rel="dialog"><?php echo $service?>&nbsp;</a></strong><em>request.</em><br>
<em>Which is due on</em>&nbsp;<strong><?php echo $duedate;?></strong>
</p>
    <?php $i++; ?>
    </div>
    &lt;script type="text/javascript">
$(document).ready(function() {
$("#Bidaccept").click(function() {
$("#viewbids").html("Bid Accepted!");
});
});
&lt;/script>
&lt;input type="submit" id="Bidaccept" data-inline="true" data-mini="true" data-theme="c" value="Accept Bid"/>
</pre>

It's alot to ask...I know, but desperate times you know, I still have to be able to incorporate comments and ratings to the completed serviceposts...plus print filterable data in pdf...so please bear with me, and go easy on me, im stressed =(!
Posted
Updated 26-Jul-15 10:02am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900