Reputation: 11
Hi I am noob in web development so I need help in a simple task. What I want to do is when user clicks on order id it will show all the parts with that order id and if user want to add something in it I want that user clicks on add part and the id of the order id to be passed to the page I want to call. But I am not able to access the value of the order id. Below is the code :
<!DOCTYPE html>
<html>
<body>
<head>
<link rel="stylesheet" type="text/css" href="Search.css">
<img src="logo.jpg" alt="Logo" id="logoImg" height="100px" width:"600px">
<div id="InputA">
<h1 id="h">Data Of Shop One</h1>
</div>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(isset($_GET["data"]))
{
$data = $_GET["data"];
$f=$data;
}
if(! $conn )
{
die('Could not connect: ' . mysqli_error());
}
$sql = "SELECT O_no, piece_name,piece_code,piece_price,piece_qty,total,comments,shipped
FROM parts Where O_no='$data'";
mysqli_select_db($conn,'shop1');
$retval = mysqli_query($conn,$sql );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
echo"
<div class='CSSTableGenerator' >
<table>
<tr>
<th>Order Number</a></th>
<th>Piece Name</th>
<th>Piece Code</th>
<th>Piece Price</th>
<th>Quantity</th>
<th>Total</th>
<th>Comments</th>
<th> Shipped</th>
</tr>
";
while($row = mysqli_fetch_array($retval, MYSQL_ASSOC))
{
echo "<h2 style='text-align:left;float:left;'>Order nuber:". $row['O_no']."</h2>";
echo "<h2 style='text-align:left;float:right;'>piece_name:". $row['piece_name']."</h2>";
echo "<tr>";
echo "<td><a href='Search.php?data=$row[O_no]' >".$row['O_no']."</a></td>";
echo "<td>". $row['piece_name']."</a></td>";
echo "<td>". $row['piece_code']."</td>";
echo "<td>". $row['piece_price']."</td>";
echo "<td>". $row['piece_qty']."</td>";
echo "<td>". $row['total']."</td>";
echo "<td>". $row['comments']."</td>";
echo "<td><input type='checkbox' name='yes' value='Yes' checked/> ". $row['shipped']."</td>";
echo "</tr>";
}
echo "</table>";
echo"</div>";
mysqli_close($conn);
?>
<input type=button onClick="parent.location='addpart.php?data='.<?php echo $data ?>" value="Add Part" id="btnOne">
</body>
</html>
Kindly suggest me a way to pass order id to the page I want to redirect. Thanks
By changing:
<input type=button onClick="parent.location='addpart.php?data='.<?php echo $data ?>" value="Add Part" id="btnOne">
To:
<input type=button onClick="parent.location='addpart.php?data=<?php echo $data; ?>'" value="Add Part" id="btnOne">
Upvotes: 0
Views: 130
Reputation:
Really simple solution
$id = ID ARGUMENT TO GET THE ID
header("Location: page.php?id='$id'");
Now you have gone to a page with a parameter now make a call to grab it
$id = $_GET['id'];
Now compare in sql or whatever you use
$sql = "SELECT * FROM placeholder WHERE placeholder='$id'";
and there you go :)
Upvotes: 1