attached is the question. I wrote the answer code, but it looks like something is wrong.
It has some small errors and the output is not exactly correct. Need your help please.
Need help in code please
Moderator: General Moderators
Re: Need help in code please
This is my code and output:
<?php
$sql=mysqli_connect("localhost","root","","a");
$show= "SELECT Item_name , Quantity ,Order_Date FROM order_items JOIN orders ON order_items.Order_Id=orders.Order_Id WHERE orders.Order_Id='".$_POST['num']."'";
$showq=mysqli_query($sql,$show);
$dateq=mysqli_query($sql,$show);
?>
<html>
<head>
</head>
<body>
<form action="three.php" method="POST">
<p>
<lable>Enter Order number:</lable>
<input type="text" name="num">
</p>
<input type="submit" name="submit">
</form>
<p>Order Number:<?php print $_POST['num']?></p>
<p>Order_date:<?php $date = mysqli_fetch_array($dateq,MYSQL_ASSOC);
print $date['Order_Date']; ?></p>
<table cellpadding="2" border="4">
<?php
if($showq){
while($info = mysqli_fetch_array($showq,MYSQL_ASSOC)){
echo'<tr>';
echo'<td>';
echo $info['Item_name'];
echo'</td>';
echo'<td>';
echo $info['Quantity'];
echo'</td>';
echo '</tr>';
}
}
?>
</table>
</body>
</html>
<?php
$sql=mysqli_connect("localhost","root","","a");
$show= "SELECT Item_name , Quantity ,Order_Date FROM order_items JOIN orders ON order_items.Order_Id=orders.Order_Id WHERE orders.Order_Id='".$_POST['num']."'";
$showq=mysqli_query($sql,$show);
$dateq=mysqli_query($sql,$show);
?>
<html>
<head>
</head>
<body>
<form action="three.php" method="POST">
<p>
<lable>Enter Order number:</lable>
<input type="text" name="num">
</p>
<input type="submit" name="submit">
</form>
<p>Order Number:<?php print $_POST['num']?></p>
<p>Order_date:<?php $date = mysqli_fetch_array($dateq,MYSQL_ASSOC);
print $date['Order_Date']; ?></p>
<table cellpadding="2" border="4">
<?php
if($showq){
while($info = mysqli_fetch_array($showq,MYSQL_ASSOC)){
echo'<tr>';
echo'<td>';
echo $info['Item_name'];
echo'</td>';
echo'<td>';
echo $info['Quantity'];
echo'</td>';
echo '</tr>';
}
}
?>
</table>
</body>
</html>