DayDreamer16 Posted July 21, 2010 Share Posted July 21, 2010 does anyone know how you would display data from a table onto a webpage? like say i insert things into my database like what ever is in the structure (title, name, number etc). Link to comment https://forums.phpfreaks.com/topic/208471-display-mysql-table-data-on-a-php-webpage/ Share on other sites More sharing options...
freelance84 Posted July 21, 2010 Share Posted July 21, 2010 do you know any php? if not a good book that got me started was: Learning PHP, MySQL, and JavaScript by o'reily Link to comment https://forums.phpfreaks.com/topic/208471-display-mysql-table-data-on-a-php-webpage/#findComment-1089307 Share on other sites More sharing options...
dsjoes Posted July 21, 2010 Share Posted July 21, 2010 if you just want to display your data in a table then this should work just change it so it works with your database <?php $con = mysql_connect("host","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database_name", $con); $result = mysql_query("SELECT * FROM table"); echo "<table border='1'> <tr> <th>name</th> <th>number</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['number'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/208471-display-mysql-table-data-on-a-php-webpage/#findComment-1089322 Share on other sites More sharing options...
Kryllster Posted July 21, 2010 Share Posted July 21, 2010 Here is an example of a table I have working atm. echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"15\">"; echo "<tr>"; $i=0; while ($i < $num) { $skillname = mysql_result($result,$i,"skillname"); $class = mysql_result($result,$i,"class"); $type = mysql_result($result,$i,"type"); $description = mysql_result($result,$i,"description"); $name = mysql_result($result,$i,"name"); echo "<tr>\n"; echo "<td>"; echo "<hr>"; echo "<b>Skillname: </b>$skillname<br>"; echo "<b>Class: </b>$class<br>"; echo "<b>Skill Type: </b>$type<br>"; echo "<b>Description:</b>$description<br>"; echo "<b>Submitted by: </b>$name<br>"; echo "<hr>"; echo "</td>"; $i++; } echo "</table>"; Hope that helps a little. Link to comment https://forums.phpfreaks.com/topic/208471-display-mysql-table-data-on-a-php-webpage/#findComment-1089323 Share on other sites More sharing options...
DayDreamer16 Posted July 22, 2010 Author Share Posted July 22, 2010 do you know any php? if not a good book that got me started was: Learning PHP, MySQL, and JavaScript by o'reily i don't know much php but i can work my way around some things. Link to comment https://forums.phpfreaks.com/topic/208471-display-mysql-table-data-on-a-php-webpage/#findComment-1089376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.