emilyfrazier Posted May 30, 2006 Share Posted May 30, 2006 Hi,This is a mySQL / php question. Thanks in advance for anyone who can help me with this; I am very close and assume my loop is in the wrong place but just can't quite get it.What I want is to have two text boxes created; one for the$u_data["url"] and another for the u_data["material"]. I needthem to stay connected. So I want an array that holds a $key of $u_data["url"]and a $value of $u_data["material"]. Then I want to create 8 text boxes, andif the above data exists, then populate the boxes with that data; otherwise leave themempty.I have done this and get redundancy of information or I only get the numberof boxes for the number of filled variables. HERE'S THE CODE:<?php $url_sql = "SELECT a.title, b.title, b.url, b.materialFROM mprogram_library AS aLEFT JOIN web_url AS b ON (a.title = b.title)WHERE a.title = '".$id."'";$url_rval = mysql_query ( $url_sql );$rows = mysql_num_rows ( $url_rval );$url_data = array();while ( $u_data = mysql_fetch_assoc ( $url_rval ) ) {$url_data[sizeof( $url_data )] = $u_data["url"];}for($i=0;$i<8;$i++){ ?><input size="20" type="text" name="web_url[<?php echo $i; ?>]"id="web_url[<?php echo $i; ?>]" value="<?phpecho isset( $url_data[$i] )?$url_data[$i]:"";?>"><?php} // End For?>Thanks again if you can help me...Emily Link to comment https://forums.phpfreaks.com/topic/10796-mysql-php-data-generated-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.