Writing order status problem

Hello! I am a beginner student, and I have a problem.
I would like to write the order items’ status. This code works, so if the order status = 0 the program writes “waiting”, else writes “delivered”. But what if I would like to add one more status (for example “shipping”) then how can I do that?
(I hope you understand my English. This is not my native language)

[php]

<?php require_once("header.php"); if (isset($_SESSION["auid"])) { ?>
<div class="container">
  <h1 class="text-center">Orders</h1>
		<table width="100%">
			<tr style="font-weight: bold;">
				<td>Order number</td>
				<td>Date</td>
				<td>Payment</td>
				<td>Order status</td>
				<td>&nbsp;</td>
			</tr>
<?php while ($record = mysqli_fetch_assoc($table)) { $status= $record["rstatus"] == 0 ? "waiting" : "delivered"; $icon = $record["rstatus"] == 0 ? "glyphicon-ok" : "glyphicon-time"; $color = $record["rstatus"] == 0 ? "text-danger" : ""; ?>
				<tr class="<?php print $color; ?>">
					<td><a class="btn btn-link" style="padding-left: 0px;" data-toggle="modal" data-target="#OrderItemsModal" onclick="OrderItemsList(<?php print $record["rfid"]; ?>)"><?php print $record["rfordernumber"]; ?></a></td>
					<td><?php print $record["rfdate"]; ?></td>
					<td><?php print $record["fname"]; ?></td>
					<td><?php print $status; ?></td>
					<td><a class="btn btn-link" href="index.php?rfid=<?php print $record["rfid"]; ?>"><span class="glyphicon <?php print $ikon; ?>"></span></a></td>
				</tr>
<?php } ?>
		</table>
	</div>
<?php } require_once("footer.php"); [/php]

I’d add another table for statuses

status
id, text, icon, color

Then refer to that in your other table(s)

order
id, date, status_id

Then join in the status fields when selecting the order(s), which means you will not need hard coded code to output starus texts, icons and colors when you need it

Sponsor our Newsletter | Privacy Policy | Terms of Service