I have no idea if the answers are correct. Please ask any question/queries in the comments sections below.
Last active
November 29, 2018 11:22
-
-
Save vamonke/b1786b36539d88394c5054ffa92092b7 to your computer and use it in GitHub Desktop.
IM4717 AY17/18 Sem 1 Answers
users
- name | varchar(255)
- pidn | varchar(9) | Primary Key
- contact | varchar(9)
- email | varchar(255)
- company_name | varchar(255)
- company_address | varchar(255)
rft
- tenderID | int(4) | Primary Key
- vendor_pidn | varchar(9) | Foreign Key
- title | varchar(100)
- sector | varchar(100)
- scope | varchar(100)
- description | text
itb
- tenderID | int(4) | Foreign Key
- supplier_pidn | varchar(9)
- bidID | int(4) | Primary Key
- cost | float
- duration | float
- warranty | float
award
- award_id | int | Primary Key | Auto increment
- bidID | int | Foreign Key
- tenderID | int | Foreign Key
$sql = "SELECT *, MIN(cost) FROM itb WHERE tenderID = 9002";
$result = mysqli_query($conn, $sql);
$row = mysql_fetch_assoc($result);
$itb = $row;
$sql = "INSERT INTO awards (bidID, tenderID) VALUES (8025, 9002)";
mysqli_query($conn, $sql);
...
$sql = 'SELECT * FROM rtf';
$results = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo " <td>".$row['tenderID']."<td/>";
echo " <td>".$row['title']."<td/>";
echo " <td>".$row['sector']."<td/>";
echo " <td>".$row['scope']."<td/>";
echo " <td>".$row['description']."<td/>";
echo " <td>";
echo " <a href='newpage.php?tenderID=".$row['tenderID']."'>";
echo " <img src='button.jpg'>";
echo " </a>";
echo " <td/>";
echo "<tr>";
}
} // else: no tenders
...In the href attribute of <a>, tenderID is added to the back of newpage.php as a query parameter. E.g. if tenderID = 9002, target URL = newpage.php?tenderID=9002.
<a href='newpage.php?tenderID=".$row['tenderID']."'>
| TenderID | Tender Title | Sector | Scope | Click to Bid (in HTML) |
|---|---|---|---|---|
| 9001 | School Projects | Education | National | <a href='newpage.php?tenderID=9001'><img src='button.jpg'></a> |
| 9002 | Building Automation | Industrial | Local | <a href='newpage.php?tenderID=9002'><img src='button.jpg'></a> |
| 9003 | Rapid Rail links | Transportation | Regional | <a href='newpage.php?tenderID=9003'><img src='button.jpg'></a> |
| ... | ... | ... | ... | ... |
tenderID is in query parameters of URL (e.g. http://localhost:8080/newpage.php?tenderID=9002), which can be retreived from $_GET.
// newpage.php
$tenderID = $_GET['tenderID'];
...
echo "$tenderID";
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment