Re: Passing contents of array on as variables...
| From: | jas | Date: | Mon, 25 Feb 2002 06:14:27 +0000 |
| Subject: | Re: Passing contents of array on as variables... | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17275@lists.php.net to get a copy of this message | ||
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
> >
>
>
>
> --
>
>
>