Posted by Justin Koivisto on 12/05/05 20:08
Stephen Preston wrote:
> I can't get an $array[key] to be used as a select query on a mySQL database.
<sni
> To display the contents of the posted array.
> It is shown below how it prints out. The Key refers to a line entry (id) in
> the database.
> The right hand entry is a quantity input by the user on the previous page.
>
> Array
> (
> [63] => 5
> [64] => 0
> [65] => 6
> [66] => 25
> [67] => 0
> )
>
> The basket page needs to pull these requsted rows (id) from the database.
>
> I have tried various combinations of MySQL queries but can't seem to get the
> data into a $query.
>
>
> $query = "SELECT * FROM z350 WHERE id=\"{$basket[id]}\"";
> $result = mysql_query($query)
> or die ("Couldn't execute query.");
>
> I beleive the state of play with the above is that the key is not being
> looked at, its the value.
> So how do I make the key into the values that will be used in the SQL query.
foreach($basket as $id=>$val){
$query = "SELECT * FROM z350 WHERE id='{$id}'";
...
}
HTH
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
Navigation:
[Reply to this message]
|