oursler Posted August 25, 2009 Share Posted August 25, 2009 I'm trying to select and print info from my database to a php page. I can't seem to figure this out. Please help. <?php $con = mysql_connect("localhost","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Events"); while($row = mysql_fetch_array($result)) { echo $row['ename'] . $row['date'] . $row['time']; echo "<br />"; } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/171787-sql-database-to-php/ Share on other sites More sharing options...
kenrbnsn Posted August 25, 2009 Share Posted August 25, 2009 Are you having any problems? Any errors? Ken Link to comment https://forums.phpfreaks.com/topic/171787-sql-database-to-php/#findComment-905843 Share on other sites More sharing options...
oursler Posted August 25, 2009 Author Share Posted August 25, 2009 no errors, i just can't get it to print the info from the database to the page that this is on Link to comment https://forums.phpfreaks.com/topic/171787-sql-database-to-php/#findComment-905865 Share on other sites More sharing options...
otuatail Posted August 25, 2009 Share Posted August 25, 2009 If you are not getting any errors. IE die('Could not connect: ' . mysql_error()); Are there any records to return? Run the query directly on the database. and see the results. Des. Link to comment https://forums.phpfreaks.com/topic/171787-sql-database-to-php/#findComment-905942 Share on other sites More sharing options...
YourNameHere Posted August 25, 2009 Share Posted August 25, 2009 Try doing $recCount = mysql_num_rows($result); then in your while loop while ($t < $recCount){ $column=mysql_result($recResult,$t,column_name); $column2=mysql_result($recResult,$t,column_name2); $column3=mysql_result($recResult,$t,column_name3); //echo code $t++; } Link to comment https://forums.phpfreaks.com/topic/171787-sql-database-to-php/#findComment-906035 Share on other sites More sharing options...
oursler Posted August 25, 2009 Author Share Posted August 25, 2009 thanks, got it Link to comment https://forums.phpfreaks.com/topic/171787-sql-database-to-php/#findComment-906136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.