Wednesday, July 8, 2009

Re: [PHP_MySQL] Need help with combo



With a little javacript goodness, you can chain select boxes. Essentially
when the first 'select' is chosen, you can have an ajax call to your php
script, have it grab the contents for the next box, and inject it. With
jQuery this can be accomplished with very little code.
There should be some great examples online.

For using SQL via PHP, a good start would be something like:

$tbl = 'foo';
$id = 4;
$sql = "SELECT * FROM {$tbl} WHERE id = {$id}";
$res - mysql_query($sql);

And some reading at php.net/mysql wont hurt.

To update, it would be:

UPDATE `table` SET `field`=value WHERE `field` = 'value';

Hope this helps,

Jason Straughan
http://tutlist.com

On Wed, Jul 8, 2009 at 12:18 PM, Reid <reidsim@gmail.com> wrote:

>
>
> Jason,
>
> Thank you and now it is working. Next thing I need to get more information
> from table into fill out text box. I do not know much about combo. When we
> select the item from combo, can it bring inforamation from table into text
> boes? Or do we need a button to get information from tables into text
> boxes?
> I am create a form to get information from table into different text box
> for
> update if needs. I will use UPDATE SET. I am still learning how to do that.
> I do know how to update on mysql but not on PHP.
>
> Reid
> On Wed, Jul 8, 2009 at 10:11 AM, Jason Straughan <jdstraughan@gmail.com<jdstraughan%40gmail.com>
> >wrote:
>
>
> >
> >
> > Well, at first glance it looks like you are using the wrong operator for
> > concatenation.
> >
> > $both[full_name] = ($row[first_name]) + ' ' + ($row[last_name]);
> >
> > Should be:
> > $both[full_name] = ($row[first_name]) . ' ' . ($row[last_name]);
> >
> > In PHP the . is the concat operator, not the +
> >
> > Hope this helps,
> >
> > Jason Straughan
> > http://tutlist.com
> >
> > On Tue, Jul 7, 2009 at 9:39 PM, rsimonus <reidsim@gmail.com<reidsim%40gmail.com>
> <reidsim%40gmail.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]
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
>
>

[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
Give Back

Yahoo! for Good

Get inspired

by a good cause.

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___

0 Comments: