XCVIII Posted August 12, 2012 Share Posted August 12, 2012 I have created a form that outputs information to my mysql data. For example if I enter a value in a text field the value gets sent to the database and is stored as $example="value" There is a populated list and its set up like this: <?php $example1="value1"; $example2="value2"; $example3="value3"; $example4="value4"; $example5="value5"; $example6="value6"; ?> So far everything is working, I am able to store information in the database. However when I try to echo the information in my page it doesn't come up at all, its blank. I can however echo the whole table but then it comes up like this: <?php $example1="value1"; $example2="value2"; $example3="value3"; $example4="value4"; $example5="value5"; $example6="value6"; ?> I need to echo the values separately in a text, e.g. This is an example $example1 and this is what $example2 I need, I need to echo $example3 the values individually $example 4 etc $example5 I don't know what I'm doing wrong, echoing the whole table works with: $zeile=mysql_fetch_array($ger); echo("\n".$seile['code']."\n"); But id like to do it separately. Quote Link to comment https://forums.phpfreaks.com/topic/266987-need-help-echoing-values/ Share on other sites More sharing options...
Christian F. Posted August 12, 2012 Share Posted August 12, 2012 I think you should start with the PHP manual tutorial. Then read up on PHP arrays and "mysql_fetch_array ()". PS: Do note that the mysql_* () functions are deprecated, and that you should use MySQLi or PDO instead. (Read more about them in the manual.) Quote Link to comment https://forums.phpfreaks.com/topic/266987-need-help-echoing-values/#findComment-1368861 Share on other sites More sharing options...
vinsux Posted August 13, 2012 Share Posted August 13, 2012 Like this?? $check = mysql_query("SELECT * FROM YourtableName")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { $example1="value1"; $example2="value2"; $example3="value3"; echo "$example1"; } Quote Link to comment https://forums.phpfreaks.com/topic/266987-need-help-echoing-values/#findComment-1368897 Share on other sites More sharing options...
Christian F. Posted August 13, 2012 Share Posted August 13, 2012 There is no point in using single variables, use arrays instead. Will give you a lot less headaches working with the code. Trust me. Quote Link to comment https://forums.phpfreaks.com/topic/266987-need-help-echoing-values/#findComment-1368999 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.