Re: Passing contents of array on as variables...

From: Date: Mon, 25 Feb 2002 18:27:12 +0000
Subject: Re: Passing contents of array on as variables...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17278@lists.php.net to get a copy of this message
You didn't add the value part of the hidden element, ie. <INPUT TYPE=\"hidden\" NAME=\"car_type\" value=\"$myrow[car_type]\"> You were naming the field as an array with no value. if you want to pass this as an array of values, you would need to use: <INPUT TYPE=\"hidden\" NAME=\"car_type[]\" value=\"$myrow[car_type]\"> Give that a try and see if it works. HTH MB jas <jlgerfen@hotmail.com> said: > As of right now if you run the php script and view source on the page you > can see that it does place the content of db table into array... ex. > <B>Current Inventory</B></font><hr > color="333333"></td></tr> > <INPUT TYPE="hidden" NAME="car_type[Ford]"> > <INPUT TYPE="hidden" NAME="car_model[Ranger]"> > <INPUT TYPE="hidden" NAME="car_year[1999]"> > <INPUT TYPE="hidden" NAME="car_price[5600]"> > <INPUT TYPE="hidden" NAME="car_vin[no vin]"> > <tr><td width="30%"><B>Type Of Car: > </B></td><td>Ford</td><td><input > type="checkbox" name="id[1]">remove</td></tr> > but on the following page (after selecting items to delete) it just displays > the word array for each field (i.e. car_type etc.) > > "Jas" <jlgerfen@hotmail.com> wrote in message > news:20020225180612.7245.qmail@pb1.pair.com... > > Oops... yeah its a monday. > > Bjorn, I reverted back to my original code because I was getting > confused... > > Here is page one... > > <?php > > // Database connection paramaters > > require '../path/to/db.php'; > > // SQL statement to get current inventory > > $result = @mysql_query("SELECT * FROM cur_inv",$dbh) or die("Could not > > execute query, please try again later"); > > // Creating table to make data look pretty > > echo "<table border=\"0\" class=\"table-body\" > > width=\"100%\"><form > > name=\"rem_inv\" method=\"post\" > > action=\"rem_conf.php3\"> > > <tr><td align=\"center\" colspan=\"3\"><font > > size=\"4\"><B>Current > > Inventory</B></font><hr > > color=\"333333\"></td></tr>"; > > // Start to count number of records in selected table and loop until done > > $count = -1; > > while ($myrow = mysql_fetch_array($result)) { > > $count ++; > > // Begin placing them into an hidden fields and then array > > echo " > > <INPUT TYPE=\"hidden\" > > NAME=\"car_type[".$myrow[car_type]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_model[".$myrow[car_model]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_year[".$myrow[car_year]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_price[".$myrow[car_price]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_vin[".$myrow[car_vin]."]\"> > > // Place items on separate cells in html table > > <tr><td width=\"30%\"><B>Type Of Car: > > </B></td><td>"; > > printf(mysql_result($result,$count,"car_type")); > > // Create checkbox so user can delete items if needed > > echo "</td><td><input type=\"checkbox\" > > name=\"id[".$myrow[id]."]\">remove</td></tr>\n"; > > echo "<tr><td width=\"30%\"><B>Model Of Car: > > </B></td><td>"; > > printf(mysql_result($result,$count,"car_model")); > > echo "</td></tr>\n"; > > echo "<tr><td width=\"30%\"><B>Year Of Car: > > </B></td><td>"; > > printf(mysql_result($result,$count,"car_year")); > > echo "</td></tr>\n"; > > echo "<tr><td width=\"30%\"><B>Price Of Car: > > </B></td><td>$"; > > printf(mysql_result($result,$count,"car_price")); > > echo "</td></tr>\n"; > > echo "<tr><td width=\"30%\"><B>VIN Of Car: > > </B></td><td>"; > > printf(mysql_result($result,$count,"car_vin")); > > echo "</td></tr><tr><td colspan=\"3\"><hr > > color=\"333333\"></td></tr>\n"; > > } > > // End loop and print the infamous delete button > > echo "<tr><td><input type=\"submit\" > > name=\"delete\" > > value=\"delete\"></td></tr></form></table>"; > > ?> > > Here is page two... > > <?php > > print(" > > <table border=\"0\" class=\"table-body\" > > width=\"100%\"> > > <form name=\"rem_inv\" method=\"post\" > > action=\"done2.php3\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_type[".$myrow[car_type]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_model[".$myrow[car_model]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_year[".$myrow[car_year]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_price[".$myrow[car_price]."]\"> > > <INPUT TYPE=\"hidden\" > > NAME=\"car_vin[".$myrow[car_vin]."]\"> > > <tr> > > <td align=\"center\" colspan=\"3\"><font > > size=\"4\"><B>Confirm Record > > Deletion</B></font><hr color=\"333333\"></td> > > </tr> > > <tr> > > <td width=\"30%\"><B>Type Of Car: </B></td> > > <td>$car_type</td> // here is where it prints the word "array" > > instead of > > type of car > > </tr> > > <tr> > > <td width=\"30%\"><B>Model Of Car: </B></td> > > <td>$car_model</td> > > </tr> > > <tr> > > <td width=\"30%\"><B>Year Of Car: </B></td> > > <td>$car_year</td> > > </tr> > > <tr> > > <td width=\"30%\"><B>Price Of Car: </B></td> > > <td>$car_price</td> > > </tr> > > <tr> > > <td width=\"30%\"><B>VIN Of Car: </B></td> > > <td>$car_vin</td> > > </tr> > > <tr> > > <td colspan=\"3\"><hr color=\"333333\"></td> > > </tr> > > <tr> > > <td><input type=\"submit\" name=\"delete\" > > value=\"delete\"></td> > > </tr> > > </form> > > </table>"); > > ?> > > > > <biorn@ebmstpa.com> wrote in message > > news:200202251800.LAA22108@www2.ebmstpa.com... > > > Let's see what your code looks like now and where it is returning the > > > word "array". That might help determine where the problem lies now. > > > > > > MB > > > > > > jas <jlgerfen@hotmail.com> said: > > > > > > > Ok to this point I have been able to query a database table, display > the > > > > results in tables and within a form. As of yet I have been able to > > insert > > > > the contents of the db query into an array for further processing. > > However, > > > > when I try to pass the contents of that array on to another page to > > delete > > > > selected records from the db it only displays the word "array". Not > > quite > > > > sure where I need to go from here... Any insight would be a great > help. > > > > Thanks in advance, > > > > Jas > > > > > > > > > > > > > > > > -- > > > > PHP Database Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: > > > > http://www.php.net/unsub.php > > > > > > > > > > > > > > > > -- > > > > > > > > > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --

« previous php.db (#17278) next »