Jump to content

How to fetch data from two tables


mmarif4u

Recommended Posts

Hi everybody..

I am facing some problem to fetch data from two tables..
I have two tables.one is loguser other is access.
In loguser thier is icnumber and creationdate fields In access their
is acccode field now i want to print results from these two
tables...
i try the query but gives error...
Error is (Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\Arif\Doc Drive\WWW\reg1\admin.php on line 159)
And cannot print the results..while i have also code to insert it
1st to tables..

Code are here:

[code]
<?php
$con = mysql_connect("localhost","root","adil");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("db", $con);

$query = ("SELECT loguser.icnumber,access.acccode,DATE_FORMAT(loguser.creationdate, '%d/%m/%Y')AS formatteddate,
          FROM loguser,access where icnumber = '$ic'");
$result = mysql_query($query);

echo "<table align=Center CELLSPACING='0'BORDERCOLOR='#007FFF' BGCOLOR='cornsilk' border='1'>



<tr><th colspan=12><Font face='Verdana'size='3'>User Activation Details</th></Font>
<tr>
<th><Font face='Verdana'size='2'>IC Number</th></Font>
<th><Font face='Verdana'size='2'>Access Code</th></Font>
<th><Font face='Verdana'size='2'>Date & Time</th></Font>

</tr></tr>";while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><Font face='Verdana'>" . $row['icnumber'] . "</td></font>";
  echo "<td><Font face='Verdana'size='4'>" . $row['acccode'] . "</td></font>";
  echo "<td><Font face='Verdana'>" . $row['formatteddate'] . "</td></font>";
 
  echo "</tr>";
  }
echo "</table>";mysql_close($con);
[/code]

I try my best to overcome on this prob but cant
can any one help me...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.