Re: Cant get this one

From: Date: Thu, 01 Feb 2001 20:21:44 +0000
Subject: Re: Cant get this one
Groups: php.general 
Request: Send a blank email to php-general+get-37708@lists.php.net to get a copy of this message
It looks like your not assigning the arrays correctly. Here's a long piece of code I use: (it has alot of extra code that you don't need.) <? // Create Connection $connection = mysql_connect("sql.server.com", "username", "passwd") or die ("Couldn't connect to the database!"); // Select Database $db = mysql_select_db("table_name", $connection) or die ("Couldn't connect to Database!"); //Create SQL Statement $sql = "SELECT title, price, description, image FROM featured WHERE image='$sel_record'"; //Execute SQL query and get results $sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query"); if (!$sql_result) { print ("<P>Couldn't get list!"); } else { while ($row = mysql_fetch_array($sql_result)) { $title = addslashes($row["title"]); $price = $row["price"]; $image = $row["image"]; $description = addslashes($row["description"]); $fmt_price = sprintf("%0.2f", $price); $fmt_title = stripslashes($title); $fmt_desc = stripslashes($description); echo " <table border=\"0\" cellpadding=\"5\"> <tr> <td align=\"right\">Title:</td> <td>$fmt_title</td> </tr> <tr> <td valign=\"top\">Description:</td> <td><textarea name=\"description\"cols=\"65\" rows=\"5\">$fmt_desc</textarea></td> </tr> <tr> <td align=\"right\">Price:</td> <td><input type=\"text\" name=\"price\" value=\"$fmt_price\" size=\"15\"></td> </table> <input type=\"hidden\" name=\"title\" value='$fmt_title'> "; } } ?> "Mike" <mpeloso@princeton.edu> wrote in message news:<95c33h$5a3$1@toye.p.sourceforge.net>... > Im trying to create an edit page for database records on the fly.I get all > the fieldnames and all the textboxes but only the first textbox has data.the > rest are always empty.any suggestions? > > for ($i =0;$i<mysql_num_fields($result);$i++) > { > > $row = mysql_fetch_row($result); > $name=mysql_field_name($result,$i); > echo "<p>$name<input type='text' value='$row[$i]' > name='T1' > size='20'></p>"; > } > > > Thanks > Mike P > mpeloso@princeton.edu > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#37708) next »