Jump to content

Is it possible to show a rows of a table, then plain text, then some more rows?


jaydeesmalls

Recommended Posts

I hope this makes sense.

 

I have some text, describing what going to be in this table, then I have this:

 

<?php

$query="SELECT * FROM $tbl_name WHERE user_id >'1' AND user_id <'4'";

$result=mysql_query($query);

 

echo "<table border='0'>";

echo "<tr>";

echo "<th>Name</th><th>Email</th>";

echo  "</tr>";

 

while ($row = mysql_fetch_array($result))

{

echo "<tr>";

echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>";

echo "</tr>";

}

 

Then I want to have some more text describing what's going to be in the next table, and I want this:

 

<?php

$query="SELECT * FROM $tbl_name WHERE user_id >'3' AND user_id <'9'";

$result=mysql_query($query);

 

echo "<table border='0'>";

echo "<tr>";

echo "<th>Name</th><th>Email</th>";

echo  "</tr>";

 

while ($row = mysql_fetch_array($result))

{

echo "<tr>";

echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>";

echo "</tr>";

}

 

But it's not working for me.  It will either print out the first $query result, or not print anything at all.

 

Is it possible to do this?

 

Thank you

I don't see anything wrong with the code, other than the lack of ending php marks  "?>"  in their proper places.

 

<?php

$query="SELECT * FROM $tbl_name WHERE user_id >'1' AND user_id <'4'";

$result=mysql_query($query);

 

echo "<table border='0'>";

echo "<tr>";

echo "<th>Name</th><th>Email</th>";

echo  "</tr>";

 

while ($row = mysql_fetch_array($result))

{

echo "<tr>";

echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>";

echo "</tr>";

}

?>          //  -- this line was added

 

Then I want to have some more text describing what's going to be in the next table, and I want this:

 

<?php

$query="SELECT * FROM $tbl_name WHERE user_id >'3' AND user_id <'9'";

$result=mysql_query($query);

 

echo "<table border='0'>";

echo "<tr>";

echo "<th>Name</th><th>Email</th>";

echo  "</tr>";

 

while ($row = mysql_fetch_array($result))

{

echo "<tr>";

echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>";

echo "</tr>";

}

?>  // this line was added

 

 

I would also suggest you call the link reference you captured from mysql connect, in your mysql_query function.

ex:

$result=mysql_query($query,$link);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.