Re: A real problem
| From: | Daniel Clark | Date: | Mon, 26 Apr 2004 19:31:22 +0000 |
| Subject: | Re: A real problem | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184691@lists.php.net to get a copy of this message | ||
If I was displaying it. :-)
Here is a "ruff" guess.
<?
$query = "SELECT id, name FROM shop_brands";
$result = mysql_query($query) or die("error in query - $query
".mysql_error());
while($row = mysql_fetch_row($result)) {
list($brand_id, $brand_name) = $row;
$query2 = "SELECT * FROM shop_models WHERE brand_id = $brand_id";
$result2 = mysql_query($query2) or die("error in query - $query2 -
".mysql_error());
$rows = mysql_num_rows($result2);
if($rows) {
$brand_name = htmlspecialchars(stripslashes($brand_name));
if(!$save_brand_id) $save_brand_id = $brand_id;
echo("<option value='$brand_id'>$brand_name</option>");
$query = "SELECT id, name FROM shop_models WHERE
brand_id=$save_brand_id";
$result = mysql_query($query) or die("error in query - $query -
".mysql_error());
while($row2 = mysql_fetch_row($result)) {
list($model_id, $model_name) = $row2;
echo "$model_id -- $model_name" . "<BR>";
};
}
}
?>
> I understand. I think the only solution is to be displayed in html. Please
> show me on this example where to put shop_models query and output within
> your shop_brands.
>
> Sorry for disturbing you...
>
>
> ----- Original Message -----
> From: "Daniel Clark" <dclark@nwlink.com>
> To: "Phpu" <phpu@go.ro>
> Cc: <dclark@nwlink.com>
> Sent: Monday, April 26, 2004 10:20 PM
> Subject: Re: [PHP] A real problem
>
>
>> My mistake. I didn't realize it was a drop down SELECT. I thought it
>> was displaying the data in HTML.
>>
>>
>> A Javascript function could do it in the client's browser, without
>> another
>> trip to the server. But I couldn't tell you how at this point.
>>
>>
>>
>> > I don't quite understand... Can you show me on this example?
>> > PS. I need java todo this, because i do not know java.
>> >
>> >
>> > ----- Original Message -----
>> > From: "Daniel Clark" <dclark@nwlink.com>
>> > To: "Phpu" <phpu@go.ro>
>> > Cc: <php-general@lists.php.net>
>> > Sent: Monday, April 26, 2004 9:53 PM
>> > Subject: Re: [PHP] A real problem
>> >
>> >
>> >> Yes, put your shop_models query and output within your shop_brands.
>> >>
>> >> > Hi
>> >> >
>> >> > I have this list that interogates the database and display the name
> of
>> > the
>> >> > brand.
>> >> > <select name="brand">
>> >> > <?
>> >> >
>> >> > $query = "SELECT id, name FROM shop_brands";
>> >> >
>> >> > $result = mysql_query($query) or die("error in query - $query
>> -
>> >> > ".mysql_error());
>> >> >
>> >> > while($row = mysql_fetch_row($result)) {
>> >> >
>> >> > list($brand_id, $brand_name) = $row;
>> >> >
>> >> > $query2 = "SELECT * FROM shop_models WHERE brand_id =
>> >> $brand_id";
>> >> >
>> >> > $result2 = mysql_query($query2) or die("error in query -
>> > $query2 -
>> >> > ".mysql_error());
>> >> >
>> >> > $rows = mysql_num_rows($result2);
>> >> >
>> >> > if($rows) {
>> >> >
>> >> > $brand_name = htmlspecialchars(stripslashes($brand_name));
>> >> >
>> >> > if(!$save_brand_id) $save_brand_id = $brand_id;
>> >> >
>> >> > echo("<option
>> >> > value='$brand_id'>$brand_name</option>");
>> >> >
>> >> > }
>> >> >
>> >> > }
>> >> > ?>
>> >> >
>> >> > each brand has more than one model.
>> >> > when i chose one of the brands i want to be displayed o form like
> this
>> > (in
>> >> > real time):
>> >> >
>> >> > $query = "SELECT id, name FROM shop_models WHERE
>> >> > brand_id=$save_brand_id";
>> >> >
>> >> > $result = mysql_query($query) or die("error in query - $query
>> -
>> >> > ".mysql_error());
>> >> >
>> >> > while($row = mysql_fetch_row($result)) {
>> >> >
>> >> > list($model_id, $model_name) = $row;
>> >> > echo ("<input type='checkbox'
>> >> > value=\"$model_id\">$model_name\n");
>> >> >
>> >> >
>> >> > };
>> >> >
>> >> >
>> >> > How can i do this? (maybe java could help me but i do not know how
>> to
>> >> do
>> >> > it)
>> >> >
>> >> > Can someone plese help me?
>> >> >
>> >> >
>> >> > Thanks for your reply
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>