That's not Array Hell, this is Array Hell:

$Hell = array("satan","fire","brimstone");

-Mike


> -----Original Message-----
> From: jas [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 22, 2002 4:37 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Array HELL!!!!
>
>
> I don't know what it is but I am having a hell of a time trying
> to get some
> results of a query setup into an array or variable (too much of a
> newbie to
> know which) that can be passed to a confirmation page before deleting the
> record from a table.  I have given up working on this but for those of you
> that want to finish it here is the code and the table structure...
>
> [Table Structure]
> id int(30) DEFAULT '0' NOT NULL auto_increment,
>    car_type varchar(30),
>    car_model varchar(30),
>    car_year varchar(15),
>    car_price varchar(15),
>    car_vin varchar(25),
>    dlr_num varchar(25),
>    PRIMARY KEY (id)
>
> [Page 1 - Queries DB table for records]
> <?php
> require '../path/to/db.php';
> $result = @mysql_query("SELECT * FROM cur_inv",$dbh) or die("Could not
> execute query, please try again later");
> 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>";
> $count = -1;
> while ($myrow = mysql_fetch_array($result)) {
>  $id = $row["id"];
>  $car_type = $row["car_type"];
>  $car_model = $row["car_model"];
>  $car_year = $row["car_year"];
>  $car_price = $row["car_price"];
>  $car_vin = $row["car_vin"];
>  $count ++;
> echo "<tr><td width=\"30%\"><B>Type Of Car: </B></td><td>";
> printf(mysql_result($result,$count,"car_type"));
> echo "</td><td><input type=\"checkbox\" name=\"id[]\"
> value=\"".$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";
> }
> echo "<tr><td><input type=\"submit\" name=\"delete\"
> value=\"delete\"></td></tr></form></table>";
> ?>
>
> [Page 2 - Takes records and confirms which ones to be deleted]
> <?php
> print("
> <table border=\"0\" class=\"table-body\" width=\"100%\">
> <form name=\"rem_inv\" method=\"post\" action=\"done2.php3\">
> <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">
> <INPUT TYPE=\"hidden\" NAME=\"car_type\" VALUE=\"$car_type\">
> <INPUT TYPE=\"hidden\" NAME=\"car_model\" VALUE=\"$car_model\">
> <INPUT TYPE=\"hidden\" NAME=\"car_year\" VALUE=\"$car_year\">
> <INPUT TYPE=\"hidden\" NAME=\"car_price\" VALUE=\"$car_price\">
> <INPUT TYPE=\"hidden\" NAME=\"car_vin\" VALUE=\"$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>
>   </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>");
> ?>
>
> [Page 3 - Connects to DB and deletes selected records]
> <?php
> require '../path/to/db.php';
> $table_name = "cur_inv";
> $sql = "DELETE FROM $table_name WHERE id = '$id'";
> echo($sql);
> $result = mysql_query($sql,$dbh) or die(mysql_error());
> print("<body bgcolor=\"ff9900\"><p class=\"done\">You have successfully
> removed your items from the database.");
> ?>
>
> If anyone has the time to finish it or give me some pointers on what the
> hell I am doing wrong please let me know, I would be very glad to
> hear your
> opinion and the correct way to accomplish this.  (And, yes I went through
> just about every tutorial I could find on how to delete records, which by
> the way did nothing for putting the results of a select statement into an
> array or variable for futher processing.) Have a good weekend everyone!!!
> Pissed and frustrated...
> 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

Reply via email to