Justafriend Posted April 24, 2013 Share Posted April 24, 2013 2 problems 1st one is of course the major one i was following a tutorial online and ended up with this code <html> <head> <title> Email List</head> <style type="text/css"> table { border: 2px solid red background-color: #ffc; } th { border-bottom: 5px solid#000; } td { border bottom: 2px solid #666; } </style> </head> <body> <h1> Email List </h1> <?php $dbcon = mysql_connect("localhost","dbs_dbs","password","dbs_forms") or die("Can not connect: " . mysql_error()); $sqlget = "SELECT * From playersemails" $sqldata = mysql_query ($dbcon, $sqlget)or die("Can not connect: " . mysql_error()); echo "<table>"; echo "<tr><th>Players Name</th><th>Email address></th></tr> while($row = mysql_fetch_array($sqldata, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row[`playersname`]; echo </td><td> echo $row[`email`]; echo "</td></tr>; } echo "</table>"; ?> </body> </html> now the problem is when i run it it just comes back with a blank page that is the first issue now also in this tutorial i also noticed that the results didnt come back alphabetical and if it is possible i would like to have my table alphabetical by player name Link to comment https://forums.phpfreaks.com/topic/277261-dbs-data-retrieval/ Share on other sites More sharing options...
Justafriend Posted April 24, 2013 Author Share Posted April 24, 2013 ok well looking further into it i found a simpler code and used it but now still need to get it to go alphabetical here is the new code <html> <body> <?php $db = mysql_connect("localhost", "dbs_dbs","dbs4evr"); mysql_select_db("dbs_forms",$db); $result = mysql_query("SELECT * FROM playersemails",$db); echo "<table border=1>"; echo "<tr><td>Players Name</td><td>Email</tr>"; while ($myrow = mysql_fetch_row($result)) { printf("<tr><td>%s</td><td>%s</td></tr>", $myrow[1], $myrow[2], $myrow[3]); } echo "</table>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/277261-dbs-data-retrieval/#findComment-1426408 Share on other sites More sharing options...
mac_gyver Posted April 24, 2013 Share Posted April 24, 2013 the first code you posted has a fatal php syntax error (you can see where it is at in the code because the syntax highlighting in your post stops changing colors.) you should set php's error_reporting to E_ALL and display_errors to on in your php.ini to get php to display all types of errors. time for some mysql basics. the following is the syntax prototype for a SELECT query (it and a lot of useful information can be found in the mysql documentation at - http://dev.mysql.com/doc/refman/5.5/en/index.html ). i have highlighted the part of the syntax that would get the result set in alphabetical order (the default is ASC ascending) - SELECT[ALL | DISTINCT | DISTINCTROW ][HIGH_PRIORITY][sTRAIGHT_JOIN][sql_SMALL_RESULT] [sql_BIG_RESULT] [sql_BUFFER_RESULT][sql_CACHE | SQL_NO_CACHE] [sql_CALC_FOUND_ROWS]select_expr [, select_expr ...][FROM table_references[WHERE where_condition][GROUP BY {col_name | expr | position}[ASC | DESC], ... [WITH ROLLUP]][HAVING where_condition][ORDER BY {col_name | expr | position}[ASC | DESC], ...][LIMIT {[offset,] row_count | row_count OFFSET offset}][PROCEDURE procedure_name(argument_list)][iNTO OUTFILE 'file_name'[CHARACTER SET charset_name]export_options| INTO DUMPFILE 'file_name'| INTO var_name [, var_name]][FOR UPDATE | LOCK IN SHARE MODE]] Link to comment https://forums.phpfreaks.com/topic/277261-dbs-data-retrieval/#findComment-1426451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.