SEVIZ Posted May 12, 2009 Share Posted May 12, 2009 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 More sharing options...
sKunKbad Posted May 12, 2009 Share Posted May 12, 2009 php outputs html. echo "html"; Link to comment https://forums.phpfreaks.com/topic/157752-display-data-in-table-without-html/#findComment-832060 Share on other sites More sharing options...
SEVIZ Posted May 12, 2009 Author Share Posted May 12, 2009 Yea I know that. That is what I am currently doing. But was just curious if there was a way via php itself to just grab the data from mysql and sort it in a table. No biggy. Thanks Link to comment https://forums.phpfreaks.com/topic/157752-display-data-in-table-without-html/#findComment-832062 Share on other sites More sharing options...
sKunKbad Posted May 12, 2009 Share Posted May 12, 2009 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! Link to comment https://forums.phpfreaks.com/topic/157752-display-data-in-table-without-html/#findComment-832195 Share on other sites More sharing options...
Daniel0 Posted May 12, 2009 Share Posted May 12, 2009 php outputs html. echo "html"; Correction: PHP outputs plaintext. PHP usually outputs plaintext to a browser. A browser interprets it as HTML by default. PHP can output anything you want. Link to comment https://forums.phpfreaks.com/topic/157752-display-data-in-table-without-html/#findComment-832198 Share on other sites More sharing options...
sKunKbad Posted May 13, 2009 Share Posted May 13, 2009 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>"; Link to comment https://forums.phpfreaks.com/topic/157752-display-data-in-table-without-html/#findComment-832880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.