0
<?php
// Create connection
$con=mysqli_connect("localhost","root","root");
mysql_select_db("test") or die( "Unable to select database");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
 
 //***************************** table 1 detail ***********

$query = "SELECT * FROM fraud WHERE a_number=" . $_GET["aNun_id"];
echo "<title>" . $_GET["aNun_id"] . "</title>";         
echo "<table width='50%' border='5'>
      <tr>
    <th>Date & Time</th>
      <th>A Number</th>
      <th>B Number</th>
    <th>Status</th>
      </tr>";       

$result=mysql_query($query) or die (mysql_error());
while($row=mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $row['date'] . "</td>";
  echo "<td>" . $row['a_number'] . "</td>";
  echo "<td><a href='?bNun_id=".$row['b_number']."'>" . $row['b_number'] . "</a></td>";
  echo "<td>" . $row['status'] . "</td>";
  echo "</tr>";  
}
echo "</table>";
 
//***************************** table 2 detail ***********

//Here i'm trying to use bNum_id in below query    
$query = "SELECT * FROM fraud WHERE b_number=" . $_GET["bNun_id"];          
echo "<table width='50%' border='5'>
      <tr>
    <th>Date & Time</th>
      <th>A Number</th>
      <th>B Number</th>
    <th>Status</th>
      </tr>"; 

$result=mysql_query($query) or die (mysql_error());

while($row=mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $row['date'] . "</td>";
  echo "<td>" . $row['a_number'] . "</td>";
  echo "<td>" . $row['b_number'] . "</td>";
  echo "<td>" . $row['status'] . "</td>";
  echo "</tr>";  
}
echo "</table>";

//connection close
mysqli_close($con);
?>

Here in table one , I used aNun_id to get the data from another PHP file with "GET" command. In the table two, I want bNun_id to show its related data in that table. How do i call bNun _id data to the second table from table one. Pls help me..

5
  • 2
    WARNING: your code is wide open to MySQL injection you should use either PDO/MySQLi with prepared statements or properly sanitize the data you're receiving before using it with your MySQL queries. Commented Feb 9, 2014 at 9:52
  • $_GET["bNun_id"] - typo? Commented Feb 9, 2014 at 9:53
  • Agreed with @Prix. And you have aNun_id instead of aNum_id all over Commented Feb 9, 2014 at 9:53
  • aNun_id & bNun_id are both different. aNum_id i use to get data from another PHP & bNun i used to get data from second table shows in the code. Commented Feb 9, 2014 at 10:01
  • my 1st table is working but my second table which is data from bNun_id is not working. i think the problem in the bNun_id Commented Feb 9, 2014 at 10:05

1 Answer 1

1

Are those two tables in the same page? If so, You need to append the bNum_id to the same query string to use both aNum_id & bNum_id.

 echo "<td><a href='?aNun_id=".$_GET["aNun_id"]."&bNun_id=".$row['b_number']."'>" . $row['b_number'] . "</a></td>";
Sign up to request clarification or add additional context in comments.

1 Comment

but start of the page it's take aNun_id from another PHP file & its creates a table. When i click on the data in the table that already created then its create another table. so i hav problem in the second table.. pls help me..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.