Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey guys I have one mysql table where i have some info like user id now to display that data I need to retrieve from user table name of the user based on that id

Table tickets
<?php 


$mysql5 = mysqli_query($dbc, "SELECT * FROM tickets where status='1' ORDER BY dt DESC LIMIT 6 ");
if($indtbl = mysqli_fetch_array($mysql5))
{

  $title = $indtbl['tickettitle']; 
  $company = $indtbl['companyname'];   
  $companyid =$indtbl['compid'];  
  $trackid = $indtbl['trackid']; 
  $assignto = $indtbl['assignto'];  
  $priority = $indtbl['priority']; 
  

}
?> 

table users
<?php
$findresults2323 = mysqli_query($dbc, "SELECT * FROM users WHERE id= '$assignto'");
if($rest = mysqli_fetch_array($findresults2323))
{

  $userimg = $rest['img']; 
  $fname1 = $rest['fname'];   
  $lname1 = $rest['lname'];  

}
?>


What I have tried:

now I am trying to fetch that two array in table here is my code
 <table class="table table-hoverable">
                      <thead>
                        <tr>
                          <th class="text-left">Title</th>
                          <th>Company</th>
                          <th>Ticket ID</th>
                          <th>Assign To</th>
                          <th>Priority</th>
                          
                        </tr>
                      </thead>
                      <?php

while($rowten = mysqli_fetch_array($mysql5)) {


$retrive11 = mysqli_fetch_array($findresults2323);

?>
<tr>
    <td><a href="readit.php?id=<?php echo $rowten["id"];?>"><?php echo $rowten["tickettitle"]; ?></td>
    <td><a href="readit.php?id=<?php echo $rowten["id"];?>"><?php echo $rowten["companyname"];?> <?php echo $rowten["compid"];?></td>
    <td><a href="readit.php?id=<?php echo $rowten["id"];?>"><?php echo $rowten["trackid"]; ?></td>
    <td><a href="readit.php?id=<?php echo $rowten["id"];?>"><?php echo $retrive11['fname'];?></td>
    <td><a href="readit.php?id=<?php echo $rowten["id"];?>"><?php echo $rowten["priority"]; ?></td>
</tr>
<?php

}


?>
                    </table>

and he is retrieving first array but for second one i have this issue
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\Ticketing\demo\index.php on line 459


and this is the line 459

<td><a href="readit.php?id=<?php echo $rowten["id"];?>"><?php echo $retrive11['fname'];?></td>
Posted
Updated 8-Feb-22 15:09pm
v2
Comments
Richard MacCutchan 7-Feb-22 6:08am    
The error message that you posted above is incomplete. But it suggests that you are making a request that is missing some parameter or value. And it would help if you expalined exactly where it occurs.
Member 13084733 7-Feb-22 6:20am    
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\Ticketing\demo\index.php on line 459
Richard MacCutchan 7-Feb-22 6:22am    
So now you know which line it is on you can look at that code to see which variable is null, and why.
Member 13084733 7-Feb-22 6:55am    
the second array
Richard MacCutchan 7-Feb-22 7:02am    
Well I have no idea what you are referring to, but presumably some command did not return any data.

Suggestion: when you respond please try and provide proper details of the problem. We cannot see your screen or read your mind. For example, we have no idea where line 459 is in the code that you provided in your question, so we can only guess what you refer to.

1 solution

Hi,
I think the line of code is returning null value.
PHP
$retrive11 = mysqli_fetch_array($findresults2323);

Please debug this line by printing all the contents in the variable retrive11.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900