Jump to content

Query array question


182x

Recommended Posts

Hey guys,

 

In order to display data from sql queries in a table I have had to create two different queries and then put the results into different arrays so this can be achieved as when I preform a join query it does not seem to work.

 

I was just wondering can this be achieved with queries which make use of more than one table or are two different arrays the only way to go?

 

thanks.

 

example:

while($s1=mysql_fetch_array($query1))
{

$s2=mysql_fetch_array($query2); 
     echo "<tr class='style4'><td>".$s1['ds']."</td><td>".$s2['hy']."</td></tr>";
}

Link to comment
Share on other sites

I was just wondering can this be achieved with queries which make use of more than one table or are two different arrays the only way to go?

 

A join is the way to go if the data can be related. Maybe post your query and well try and help get it working.

Link to comment
Share on other sites

I think i got the join working but how is this data displayed in a table for example in the code below i don't think the array elements can be accessed like tableA.ds and tableB.hy

 

while($s1=mysql_fetch_array($query1))
{

$s2=mysql_fetch_array($query2); 
     echo "<tr class='style4'><td>".$s1['ds']."</td><td>".$s2['hy']."</td></tr>";
}

Link to comment
Share on other sites

Here it is.

$test=select * from tableA, tableB where tableAId = tableBId;
$query=mysql_query($test, $link_id) or die(mysql_error());

while($get=mysql_fetch_array($query))
{

     echo "<tr class='style4'><td>".$query['tableA.ds']."</td><td>".$query['tableB.hy']."</td></tr>";
}

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.