Jump to content

Recommended Posts

Is there a way to display a queries data in a table without using html?  Like some kind of php?

 

Here is my code:

<?php
$con = mysql_connect("--------","---------","----------");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("sevizcom-1", $con);

$id=$_POST['id'];
$result = mysql_query("SELECT * FROM sprint WHERE id LIKE '%$id%'");

while($row = mysql_fetch_array($result))
  {
  echo $row['id'] . " " . $row['name'] . " " . $row['num'] . " " . $row['sup'];
  }

?>
<br /><br />
<form action="techdbid.php" method="post">
Tech: <input type="text" name="id"><br />
<input type="Submit">
</form>

 

Right now the data is just one long string of the data.  How can I break it all up into a table with cells?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/157752-display-data-in-table-without-html/
Share on other sites

grab the data = the mysql_query() function

 

sort the data = include "ORDER BY 'some_field'" in your query

 

then there are numerous ways to use the returned resource and output a table, but there isn't anything automatic.

 

joke >> maybe in php7 they will implement a new hocus_pocus() function!

Why not build your table by modifying what you already have:

 

This is what you have:

while($row = mysql_fetch_array($result))
  {
  echo $row['id'] . " " . $row['name'] . " " . $row['num'] . " " . $row['sup'];
  }

 

and you could be doing this:

echo "<table>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr>
               <td>" .$row['id'] . "</td>
               <td>" . $row['name'] . "</td>
               <td>" . $row['num'] . "</td>
               <td>" . $row['sup'] . "</td>
          </tr>";
  }
echo "</table>";

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.