Jump to content

[SOLVED] Can't display half of my Query in a table - Please Help


JTapp

Recommended Posts

I just don't know if this is complicated or not.  Being that I've spent HOURS on it.. but I'm aslo a beginner...

I need to display the results of a database in a particular format.  I have two tables to pull from.

 

The problem is I need the upper half of my webpage to display the results from one table and the bottom half of my webpage to display the results of the other table and I'm using a $metode function to query everything.

 

Here is my immature and totally gutted/ code:

 

//query details

$query = mysql_query("SELECT tblLodges.strLodgeName, tblOfficers.strFirstName, tblOfficers.strLastName FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

while ($row = @mysql_fetch_array($query))

{

$variable1=$row["strLodgeName"];

$variable2=$row["strLodgeID"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeLocationCity"];

$variable5=$row["strLodgeLocationZip"];

$variable6=$row["strLodgeCounty"];

$variable7=$row["strFirstName"];

$variable8=$row["strLastName"];

 

//table layout for results

 

print ("<tr>");

echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n";

 

echo "<td class=\"td_id\">$variable2</td>\n";

echo "<td class=\"td_id\">$variable3</td>\n";

print "<td class=\"td_id\">$variable4</td>\n";

print "<td class=\"td_id\">$variable5</td>\n";

print "<td class=\"td_id\">$variable6</td>\n";

print ("</tr>");

}

?>

 

<p class="style1">Roster of Officers </p>

 

                            <hr width=75% align=center size=4>

                            <p>

 

<?php

echo "<table border='1'>

<tr>

<th>Officer First Name</th>

<th>Officer Last Name</th>

<th>Officer Business Phone</th>

<th>Officer Email</th>

 

 

</tr>";

  {

  echo "<tr>";

  echo "<td>" . $row['strFirstName'] . "</td>";

  echo "<td>" . $row['strLastName'] . "</td>";

  echo "<td>" . $row['BusinessPhone'] . "</td>";

  echo "<td>" . $row['PersEmail'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

?>

 

 

Link to comment
Share on other sites

try something like this:

<?php

$query = mysql_query("SELECT tblLodges.strLodgeName, tblOfficers.strFirstName, tblOfficers.strLastName FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

$results=mysql_query($query);
echo "<table border='1'>
   <tr>
<th>Officer Lodge Name</th>
<th>Officer Lodge ID</th>
<th>Officer City</th>
<th>Officer zip</th>
<th>Officer County</th>
<th>Officer First</th>
<th>Officer last</th>


</tr>";
while ($row = mysql_fetch_array($query))
{
$variable1=$row["strLodgeName"];
$variable2=$row["strLodgeID"];
$variable3=$row["strDistrictName"];
$variable4=$row["strLodgeLocationCity"];
$variable5=$row["strLodgeLocationZip"];
$variable6=$row["strLodgeCounty"];
$variable7=$row["strFirstName"];
$variable8=$row["strLastName"];

//table layout for results

print ("<tr>");
echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n";

echo "<td class=\"td_id\">$row[strLodgeID]</td>\n";
echo "<td class=\"td_id\">$row[strDistrictName]</td>\n";
print "<td class=\"td_id\">$row[strLodgeLocationCity]</td>\n";
print "<td class=\"td_id\">$row[strLodgeLocationZip]</td>\n";
print "<td class=\"td_id\">$row[strLodgeCounty]</td>\n";
print ("</tr>");
}
?>

<p class="style1">Roster of Officers </p>
                     
                            <hr width=75% align=center size=4>
                            <p>

<?php
echo "<table border='1'>
<tr>
<th>Officer First Name</th>
<th>Officer Last Name</th>
<th>Officer Business Phone</th>
<th>Officer Email</th>
</tr>";

while ($row = mysql_fetch_array($query))  
  {
  echo "<tr>";
  echo "<td>" . $row['strFirstName'] . "</td>";
  echo "<td>" . $row['strLastName'] . "</td>";
  echo "<td>" . $row['BusinessPhone'] . "</td>";
  echo "<td>" . $row['PersEmail'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
?>

Link to comment
Share on other sites

Here is my latest code - it is displaying Table 2 nicely in a table.  However, I need Table 1 data to be displayed at the top of the page and not in a table.  Nothing is coming up... :(

 

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeLocationCity, tblLodges.strLodgeLocationZip, tblLodges.strLodgeCounty, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

 

$results=mysql_query($query);

 

 

{

$variable1=$row["strLodgeName"];

$variable2=$row["intLodgeNumber"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeLocationCity"];

//table layout for results

 

print ("<tr>");

print ("<td>$variable1</td>");

print ("<td>$variable2</td>");

print ("<td>$variable3</td>");

print ("<td>$variable4</td>");

print ("</tr>");

}

 

 

 

 

echo "<table border='1'>

  <tr>

<th>Officer First</th>

<th>Officer Last</th>

<th>Officer Business Phone</th>

<th>Officer Email</th>

 

</tr>";

while ($row = mysql_fetch_array($query))

{

$variable1=$row["strFirstName"];

$variable2=$row["strLastName"];

$variable3=$row["BusinessPhone"];

$variable4=$row["PersEmail"];

 

 

//table layout for results

 

print ("<tr>");

echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n";

echo "<td class=\"td_id\"><h3>$variable2</h3></td>\n";

echo "<td class=\"td_id\"><h3>$variable3</h3></td>\n";

echo "<td class=\"td_id\"><h3>$variable4</h3></td>\n";

echo ("</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.