themanronnie Posted February 17, 2013 Share Posted February 17, 2013 I am running a mysql query with the code below but i cannot get the results from multiple rows in a table. I echo the results and all i get is Array. Help will be appreciated. Thank you The $row should echo all the fields under code1 in the table. Thank you mysql_connect('localhost', 'u', 'C'); mysql_select_db('u'); // $result = mysql_query("SELECT code1 FROM codes") or die(mysql_error()); $row = mysql_fetch_assoc($result); echo ("<center> <font color=#FF0000 face=Verdana size=2><b>$row</b></font>"); Quote Link to comment https://forums.phpfreaks.com/topic/274590-mysql-results-from-multiple-rows-in-database-table/ Share on other sites More sharing options...
themanronnie Posted February 17, 2013 Author Share Posted February 17, 2013 the reason for the echo statement was to see exactly what the problem was. This is what i want done To receive a variable from a form and test it against all the rows in a database column and if it finds one that corresponds to that row, then go to another page The code is below $code1=$_POST['code']; mysql_connect('localhost', 'u', 'C'); mysql_select_db('u); // $result = mysql_query("SELECT code1 FROM codes") or die(mysql_error()); $row = mysql_num_rows($result); // if ($row[0] =='$code1') { include ("mynewpage.php"); } else { echo ("<center> <font color=#FF0000 face=Verdana size=2><b>Invalid Code!</b></font>"); include("oldpage.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/274590-mysql-results-from-multiple-rows-in-database-table/#findComment-1412917 Share on other sites More sharing options...
PaulRyan Posted February 17, 2013 Share Posted February 17, 2013 (edited) echo ("<center> <font color=#FF0000 face=Verdana size=2><b>{$row['code1']}</b></font>"); *Edit: This is in response to your first post. Edited February 17, 2013 by PaulRyan Quote Link to comment https://forums.phpfreaks.com/topic/274590-mysql-results-from-multiple-rows-in-database-table/#findComment-1412922 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.