Jump to content

Recommended Posts

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 need
them 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, and
if the above data exists, then populate the boxes with that data; otherwise leave them
empty.

I have done this and get redundancy of information or I only get the number
of boxes for the number of filled variables. HERE'S THE CODE:

<?php
$url_sql = "SELECT a.title, b.title, b.url, b.material
FROM mprogram_library AS a
LEFT 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="<?php
echo 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.