Wednesday, July 8, 2009

Re: [PHP_MySQL] Need help with combo



Pl. try like this:

<?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
while($row=mysql_fetch_array($res))
{
    echo "<option>".$row['first_name']." ".$row['last_name']."</option>";
}
echo'</select> ';

?>

________________________________
From: Reid <reidsim@gmail.com>
To: PHP_MySQL_usergroup@yahoogroups.com
Sent: Wednesday, 8 July, 2009 7:49:02 PM
Subject: Re: [PHP_MySQL] Need help with combo

I tried that and it did not work. There is no error msg but when I look at
combo and click on it. It has many 0's and there is no first or last name.

If I change back to old code like
// $both['full_ name'] = ($row['first_ name']) + ' ' + ($row['last_ name']);
// echo"<option> $both[full_ name]</option> ";
echo"<option> $row[first_ name]</option> ";

This one is working only for first name. I am trying to add the last name on
it. Because some of them have same first name. I want to add last name so I
can select the right person.

Reid

On Wed, Jul 8, 2009 at 2:58 AM, James Lamb <james@jalamb. f9.co.uk> wrote:

>
>
> It would be helpful if you said what sort of error/problem you had,
> but I think you need quotes around the parameters in $row, so:
>
> $both['full_ name'] = ($row['first_ name']) + ' ' + ($row['last_ name']);
>
> otherwise they are just variables which have unset values.
>
> James
>
> At 03:39 08/07/2009, you 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> ';
> >
> >?>
> >
> >
> >
> >----------- --------- --------- -------
> >
> >----------- --------- --------- --------- ----
> >
> >Come to the monthly meetings at UTD in Richardson, TX.
> >Second Tuesday of every month.Yahoo! Groups Links
> >
> >
> >
> --
> James Lamb
>
>
>

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

Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8. http://downloads.yahoo.com/in/internetexplorer/

[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
Health Groups

for people over 40

Join people who are

staying in shape.

Yahoo! Groups

Mental Health Zone

Bi-polar disorder

Find support

Yahoo! Groups

Weight Management Challenge

Join others who

are losing pounds.

.

__,_._,___

0 Comments: