dorich Posted July 14, 2011 Share Posted July 14, 2011 Background I want to be able to UPDATE a priority field (currently set as enum with three values.). I'm a novice at using php and mysql so I found a script, shown below, to populate the form field. I set up a test page to test the script only and it worked perfectly. The next step is to integrate the script into my existing php page. My Question/Problem I thought it would be a good learning experience to reverse engineer the script so that I knew exactly what was going on, as well as figure out how to integrate it into my existing page. As you can see the script uses explode on the array derived from the query. To understand how the string was being processed I wanted to see the raw data of the the string. However, I can't see how to print the 'raw' data to the page so that I can see it and refer back to the explode function. My question is how do I see the string. Caveat I realize this isn't a problem solution type of question so perhaps its not appropriate to this forum but I'm hoping that someone can point me in the right direction so that I can educate myself on how to understand how this is working. To be clear it is the string for processing that I'm trying to get at, not the values of the fields. It would appear that this should be trivial but in spite of a lot of experiments and a few hours of searching the web I can't find an answer. Some of the novice things I've tried print $result; This prints out "Resource id #5" print $row; This prints out "Array" I'd appreciate any pointers on how to see the original string. The script I used is taken http://jadendreamer.wordpress.com/2011/03/16/php-tutorial-put-mysql-enum-values-into-drop-down-select-box/. The script is: $table_name = "your_table_name" $column_name = "field_with_enum_options"; echo "<select name="$column_name">"; $result = mysql_query("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table_name' AND COLUMN_NAME = '$column_name'") or die (mysql_error()); $row = mysql_fetch_array($result); $enumList = explode(",", str_replace("'", "", substr($row['COLUMN_TYPE'], 5, (strlen($row['COLUMN_TYPE'])-6)))); foreach($enumList as $value) echo "<option value=$value>$value</option>"; echo "</select>"; Thanks Quote Link to comment https://forums.phpfreaks.com/topic/241942-displaying-the-results-of-a-query/ Share on other sites More sharing options...
jasonc Posted July 14, 2011 Share Posted July 14, 2011 not sure if this is right but try... print_r($string); Quote Link to comment https://forums.phpfreaks.com/topic/241942-displaying-the-results-of-a-query/#findComment-1242557 Share on other sites More sharing options...
dorich Posted July 14, 2011 Author Share Posted July 14, 2011 @jasonc Thanks. Looks like that produces the correct response. I did a print_r on the array and produced the following: Array ( [0] => enum('High','Medium','Low') [COLUMN_TYPE] => enum('High','Medium','Low') ) Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/241942-displaying-the-results-of-a-query/#findComment-1242573 Share on other sites More sharing options...
jasonc Posted July 14, 2011 Share Posted July 14, 2011 Your welcome, glad I could be of some help. Quote Link to comment https://forums.phpfreaks.com/topic/241942-displaying-the-results-of-a-query/#findComment-1242574 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.