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). Quote Link to comment 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 Quote Link to comment 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); ?> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.