Tuesday, July 7, 2009

Re: [PHP_MySQL] Need help with combo



Is your code erroring out? You can do it way simpler:

foreach($query as $row){
echo "<option>$firstname, $lastname</option>"
}

Or whatever you need to do in the foreach, but the point is, if you
have an array, foreach is the best way to go

-Flynn

On Jul 7, 2009, at 7:39 PM, "rsimonus" <reidsim@gmail.com> wrote:

>
>
> I am trying to figure out how to get two columns into one combo. I
> have two columns. One column for first name and other columns for
> last name. I want first and last name in one combo. Here is my
> codes. Can someone tell me what went wrong?
>
> <?php
> include 'dbc.php';
>
> echo'<select name="categories">';
> $res=mysql_query("select * from missionary");
> if(mysql_num_rows($res)==0) echo "there is no data in table..";
> else
> for($i=0;$i<mysql_num_rows($res);$i++) {
> $row=mysql_fetch_assoc($res);
>
> $both[full_name] = ($row[first_name]) + ' ' + ($row[last_name]);
>
> echo"<option>$both[full_name]</option>";
>
> }
> echo'</select>';
>
> ?>
>
>

[Non-text portions of this message have been removed]

__._,_.___
------------------------------------------

Come to the monthly meetings at UTD in Richardson, TX.
Second Tuesday of every month.
Recent Activity
Visit Your Group
Group Charity

City Year

Young people who

change the world

Yahoo! Groups

Mom Power

Kids, family & home

Join the discussion

Weight Management Group

on Yahoo! Groups

Join the challenge

and lose weight.

.

__,_._,___

0 Comments: