RE the Dynamic Dropdown..
the javascript I've done, and I've also played with a page that
resubmits to itself if certain default dropdowns aren't populated and
have a target page if they are populated..
so.. if car_mfg is undefined then submit_target=$PHP_SELF or if car_mfg
is defined (and all you're expecting is car_model after that) then
submit_target=new page
since it's a server side scripting, I don't see any way it can know
what the client's doing.. so the best way (imo) is to either automate
it with some client-side scripting, or limit their options and base
their page off of what they submit..
dunno if that helps or makes sense..
~ Rob
Fresno, CA
php-db Digest 6 Mar 2002 16:43:13 -0000 Issue 1086
Topics (messages 17498 through 17514):
Re: Dynamic Drop Down Box
17498 by: Ralph Friedman
17508 by: Aron Pilhofer
17510 by: Edward Marczak
17511 by: Leotta, Natalie (NCI/IMS)
17513 by: Paul Burney
MySQL_connect
17499 by: Mikael_Jensen.Dell.com
17501 by: Jason Wong
17512 by: Josh Trutwin
how to make multiple in a coloum in mysql DB
17500 by: Yoga Anak Medan
17502 by: Markus Lervik
17503 by: DL Neil
Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???
17504 by: DL Neil
Re: MSSQL2000
17505 by: Andrew Hill
Re: addslashes needed for db security? Hack proving webapps
17506 by: Aron Pilhofer
Re: multiple select statements
17507 by: Aron Pilhofer
Re: RC4 encryption with PHP
17509 by: bill
php mssql* functions
17514 by: Jeremy Reed
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
In article <F3BF649E168BD411A1B700010271F38BB4BD20@SBMAIL>, Randy Rankin wrote:
> Based on the user selection, the 2nd
> drop down box would be populated with the distinct 'make' for that model
> (ie; if the user selects Ford in the first drop down, the 2nd drop down
> would be populated with Explorer, Expedition, Ranger, etc.).
>
something like SELECT Model FROM MyTable WHERE Manufacturer='Ford'
--
Rgds
Ralph
--- End Message ---
--- Begin Message ---
So, if the user selects "mercedes", then the next box is "500Sl, 300Sc" and
so forth. If they select ford, then the second box has completely different
values?
You'll either have to reload the page after the first select, or use
javascript or some other kind of client script. I don't think there is a way
to do it with PHP, but maybe someone else has an idea to help you. I hope
they do, because I need to do the same sort of thing, and I am trying to
avoid js at all costs.
"Randy Rankin" <[EMAIL PROTECTED]> wrote in message
F3BF649E168BD411A1B700010271F38BB4BD20@SBMAIL">news:F3BF649E168BD411A1B700010271F38BB4BD20@SBMAIL...
> Does anyone know how I might populate a drop down box based on the users
> selection from a previous drop down box? For example, if I have a table
> called 'autos' with 2 fields, 'make' and 'model'. I select distinct 'make'
> and populate the first drop down box. Based on the user selection, the 2nd
> drop down box would be populated with the distinct 'make' for that model
> (ie; if the user selects Ford in the first drop down, the 2nd drop down
> would be populated with Explorer, Expedition, Ranger, etc.).
>
> Thanks,
>
> Randy Rankin
>
--- End Message ---
--- Begin Message ---
On 3/5/02 3:34 PM, "Leotta, Natalie (NCI/IMS)" <[EMAIL PROTECTED]>
wrote:
> This can be done with JavaScript - I don't know if you can do it in PHP.
...unless the drop-downs are on separate pages. E.g.: page 1 just asks for
make, once selected, load up page 2 with choices appropriate to the first
drop down. Certainly, javascript is cooler.
--
Ed Marczak
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
If they want two pages they wouldn't need JS though - just submit and use
that in your second query to populate drop-down #2. I had assumed that they
wanted it on the same page - which is definitely cooler :-) Good point
though - I should have asked which way they wanted to do it. I suppose if
you really wanted to be able to say your site used JS you could still use it
to set a hidden value in the form and submit it to the next page that way.
-Natalie
> -----Original Message-----
> From: Edward Marczak [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, March 06, 2002 10:27 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Dynamic Drop Down Box
>
> On 3/5/02 3:34 PM, "Leotta, Natalie (NCI/IMS)" <[EMAIL PROTECTED]>
> wrote:
>
> > This can be done with JavaScript - I don't know if you can do it in PHP.
>
> ...unless the drop-downs are on separate pages. E.g.: page 1 just asks
> for
> make, once selected, load up page 2 with choices appropriate to the first
> drop down. Certainly, javascript is cooler.
> --
> Ed Marczak
> [EMAIL PROTECTED]
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
on 3/6/02 10:31 AM, Leotta, Natalie (NCI/IMS) at [EMAIL PROTECTED]
appended the following bits to my mbox:
> If they want two pages they wouldn't need JS though - just submit and use
> that in your second query to populate drop-down #2. I had assumed that they
> wanted it on the same page - which is definitely cooler :-) Good point
> though - I should have asked which way they wanted to do it. I suppose if
> you really wanted to be able to say your site used JS you could still use it
> to set a hidden value in the form and submit it to the next page that way.
I figured I'd throw something in too.
I personally don't like the client side scripting option because it
adversely affects accessibility. If you choose the client side option, you
should also have a non JavaScript version as well (the 2 pages mentioned
before) for site visitors that have other types of interfaces that don't
understand JavaScript or for visitors that have dynamic scripting turned off
(not a bad idea these days with all the XSS cookie stealing stuff).
That said, WebReference has a great tutorial and a bunch of code that you
can use to make the nifty related drop-down menus. You can see the theory
and tutorial here:
<http://webreference.com/dev/menus/>
And they even have a script that'll generate the code for you here:
<http://webreference.com/js/tools/menus/>
Hope that helps.
Sincerely,
Paul Burney
http://paulburney.com/
<?php
If ($your_php_version < 4.1.2) {
upgrade_now(); // to avoid major security problems
/* Please see <http://security.e-matters.de/advisories/012002.html> */
?>
--- End Message ---
--- Begin Message ---
Hi,
I'm new to MySql, when I try to connect my PHP-script with
mysql_connect($host, $user, $pass)
my script returns the error
"Fatal error: Call to undefined function: mysql_connect()"
I have given the user all rights in MySQL, both on host, DB, tables, and
fields
This might be easy for you, but I'm stuck..any help / comments are
appreciated
> Med venlig hilsen / Best regards
> Mikael Jensen
> Dell Computer A/S - Denmark
>
>
--- End Message ---
--- Begin Message ---
On Wednesday 06 March 2002 15:53, [EMAIL PROTECTED] wrote:
> Hi,
>
> I'm new to MySql, when I try to connect my PHP-script with
> mysql_connect($host, $user, $pass)
> my script returns the error
> "Fatal error: Call to undefined function: mysql_connect()"
> I have given the user all rights in MySQL, both on host, DB, tables, and
> fields
>
> This might be easy for you, but I'm stuck..any help / comments are
> appreciated
It means you do not have mysql support in PHP. If you compiled PHP yourself,
recompile it to include mysql support. If you installed it via RPM then look
for the appropriate RPMs from distro vendor.
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
Sometime when you least expect it, Love will tap you on the shoulder...
and ask you to move out of the way because it still isn't your turn.
-- N.V. Plyter
*/
--- End Message ---
--- Begin Message ---
> On Wednesday 06 March 2002 15:53, [EMAIL PROTECTED] wrote:
>
>> Hi,
>>
>> I'm new to MySql, when I try to connect my PHP-script with
>> mysql_connect($host, $user, $pass)
>> my script returns the error
>> "Fatal error: Call to undefined function: mysql_connect()"
>> I have given the user all rights in MySQL, both on host, DB, tables,
>> and fields
>>
>> This might be easy for you, but I'm stuck..any help / comments are
>> appreciated
>
> It means you do not have mysql support in PHP. If you compiled PHP
> yourself, recompile it to include mysql support. If you installed it
> via RPM then look for the appropriate RPMs from distro vendor.
A great way to check this is to create a simple script called phpinfo.php
with just this line in it, place it in your top level web directory:
<? phpinfo(); ?>
Point your browser to http://localhost/phpinfo.php (assuming the computer
you are using is your web server) You should see the ./configure command
used to compile PHP, look for --with-mysql.
Josh
--- End Message ---
--- Begin Message ---
salam,
i'm make a database in mysql, example :
name score A score A Total
john 78 90
mike 90 70
etc...
ask me is:
how to make multiple or total in coulum "Total"
otomatically, if me input score in coulom total.
please help me...
(i am sorry my english)
yoga
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
--- End Message ---
--- Begin Message ---
On Wed, 2002-03-06 at 10:02, Yoga Anak Medan wrote:
> salam,
> i'm make a database in mysql, example :
> name score A score A Total
> john 78 90
> mike 90 70
> etc...
> ask me is:
> how to make multiple or total in coulum "Total"
> otomatically, if me input score in coulom total.
> please help me...
> (i am sorry my english)
INSERT INTO table VALUES("john", "78", "90", scoreA+scoreB);
Cheers,
Markus
--
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709
--- End Message ---
--- Begin Message ---
Yoga,
wa aleikum as-salaam (tr: greetings returned to you)
> salam,
> i'm make a database in mysql, example :
> name score A score A Total
> john 78 90
> mike 90 70
> etc...
> ask me is:
> how to make multiple or total in coulum "Total"
> otomatically, if me input score in coulom total.
> please help me...
> (i am sorry my english)
Please don't feel it necessary to apologise for language difficulties.
The list language is English - and yet most of the MySQL AB people don't
speak English as their native-tongue, so ...
May I assume that the second 'score' column is labeled 'score B'?
There are two answers!
The answer to your specific question is that when you gather the data
(presumably an HTML form to PHP), after data-verification checks on
$scoreA and $scoreB, compute:
$total = $scoreA + $scoreB;
then formulate the INSERT statement accordingly.
However unless there are clear performance reasons for doing this, you
should not store "Totals" in a relation/table because the values in this
column are derived (and re-derivable) from the scores - and every time
you add a new score, the Total column would need to be changed. Better
to (only) store the scores in the table, and calculate the totals when
you retrieve the records later, eg
SELECT name, scoreA, scoreB, scoreA+scoreB AS Total FROM...
Unfortunately that comment on 'normalising' the table may also apply to
the scores themselves - should each score/result be held on its own row,
rather than having x-columns across the table. SQL/relational theory
doesn't work well this way around ('across', it prefers to go 'down') -
but that's another question.
Fee aman 'illah, (tr: go with God)
=dn
--- End Message ---
--- Begin Message ---
Hi Andy
I apologise. The way I wrote the suggestion looks very much like a SQL
query doesn't it? It wasn't!
It would have been better expressed if I had said:
retrieve the MySQL timestamp field as a UNIX (epoch) timestamp, by using
the UNIX_TIMESTAMP function within the SELECT statement
> I tryed:
> $stmt= "
> SELECT first_name, user_logindate , password
> FROM $T5
> using UNIX_TIMESTAMP()
> WHERE user_id = '$user_id'
> LIMIT 1
> ";
>
> But is is returning an error.
>
> Do u know where the syntax error is? As I did understand u right...
first
> select with this kind of statement, then format it with date(xxx,
> $timestamp)
So to 'repair the damage', please try:
$stmt= "
SELECT first_name, UNIX_TIMESTAMP( user_logindate ) AS login, password
FROM $T5
WHERE user_id = '$user_id'
LIMIT 1
";
Manual reference: 6.3.4 Date and Time Functions
The 'login' value, once fetched from the resultset, may then be fed to
PHP's DATE() (date function - see earlier msg below, manual reference
http://www.php.net/manual/en/function.date.php) and presented in any
suitably user-friendly format.
Ok now?
=dn
> > So what is the proper function in PHP to convert the MySQL timestamp
> into a
> > proper format like Sonday, Apr. 20th 2002?
>
> SELECT from SQL using UNIX_TIMESTAMP()
>
> Format for presentation in PHP using: string date ( string format [,
int
> timestamp])
>
> Regards,
> =dn
>
>
> > > > I am playing around with the timestamp functions. I created a
> timestamp
> > > > with mysql ( the row is timestamp)
> > > > and do reformat this thing after selecting with php in the
> folowíng way:
> > > >
> > > > $date_posted[$i] = strftime("%A, %d-%m-%Y %R",
$date_posted[$i]);
> > > >
> > > > This always returns Tuesday, 19-01-2038 but the mysql timestamp
> says:
> > > > 20020305211704
> > >
> > > They return the time in different formats. Read the MySQL manual
> then read
> > > the PHP manual (or vice-versa).
> > >
> > > The MySQL timestamp is human readable. So in your example above:
> > >
> > > 20020305211704 ==> 2002-03-05 21:17:04
> > >
> > > time() in PHP is the number of seconds since the Unix Epoch.
--- End Message ---
--- Begin Message ---
Mike,
You can certainly use ODBC. The drivers are already present on your system;
just configure a System DSN.
Best regards,
Andrew Hill
Director of Technology Evangelism
http://www.openlinksw.com/virtuoso/whatis.htm
OpenLink Virtuoso Internet Data Integration Server
> -----Original Message-----
> From: Mike [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 05, 2002 11:12 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] MSSQL2000
>
>
> Anybody able to get this working under a
>
> Windows2000 advanced server, IIS, PHP 4.1.1, MSSQL2000 SP2 all on one box
>
> I am beginning to believe it is not possible using any
> php_mssql.dll that i
> have ever found..... correct me if anybody can.
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
> Paul
>
> <?php
> while ($self != "asleep") {
> $sheep_count++;
> }
> ?>
I have nothing useful to add, except that I nearly spit up my morning coffee
laughing at your signature.
--- End Message ---
--- Begin Message ---
There are even easier ways to do it than that... using if statements. so,
start with something like this:
$query.="select ";
then let's say you have a buch of clickboxes which your user can check which
will construct your select statements, so,
if ($clickbox1="<value>") {
$query.="<field>";
}
if ($clickbox2="<value>") {
$query.="<anotherfield>";
}
then at the end: $query.="from <table>";
mysql_query($query)... and off you go...don't forget the little period,
otherwise it won't concat everything together as you build your query. If
you need to select from different tables, just add another variable to your
if statements..
If you want to see a real example, here's a snip I use to built an insert
statement, which will take any number of values from an array, create a
table based on their field names, and then insert them into that table..:
//start of insert...
$insert.="insert out_fuzzy set ";
$count=$count+1;
//loops through array
for ($i=0; $i<$cols_compare; $i++)
{
$insert.=mysql_field_name($result_compare, $i);
$insert.="_compare=\"";
$insert.=$compare[$i];
$insert.="\", ";
$insert.=mysql_field_name($result_compare, $i);
$insert.="_base=\"";
$insert.=$result_base[$i];
$insert.="\", ";
$insert.=mysql_field_name($result_compare, $i);
$insert.="_pct=\"";
$base_tmp=trim(strtoupper($result_base[$i]));
$compare_tmp=trim(strtoupper($compare[$i]));
$number=similar_text($base_tmp, $compare_tmp, $last_sim);
$insert.=number_format($last_sim,1);
$insert.="\", ";
Hope that helps.
aron
"Lerp" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi there :)
>
> You could construct seperate queries for every possible combination of
> search provided you don't have a huge number of search criteria (form
> elements for your search)
> .
> I did this just recently for a friend finder site. In the search the user
> has four fields that are automatically included in the search and three
more
> that are optional
>
> I built the sql queries based on every combination of the three optional
> search criterias. Since there are three optional search criterias the
number
> of queries to be built is 8 to compensate for every combination.
>
> This is one way to do it anyway:)
>
> Hope this helps you out, Joe :)
>
>
> <?php
>
> # stateprovince, country, and relationship are all optional therefor 8
> combinations for query -- use the other form values as well
>
>
> if(($country == "All") && ($stateprovince == "All") && ($relationship ==
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' ORDER BY signupdate DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2;
> }
>
> elseif(($country != "All") && ($stateprovince == "All") && ($relationship
==
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' AND country ='$country' ORDER BY
> signupdate DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2 . " from " . $country;
> }
>
>
> elseif(($country != "All") && ($stateprovince != "All") && ($relationship
==
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN '$age1'
AND '$age2' AND sexuality ='$sexuality' AND country ='$country' AND
province_state ='$stateprovince' ORDER BY signupdate DESC";
> $searchcriteria
> = $sex . " " . $sexuality . " between the ages of " . $age1 . " and " .
> $age2 . " from " . $stateprovince . ", " . $country;
>
> }
>
>
> elseif(($country != "All") && ($stateprovince != "All") && ($relationship
!=
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' AND country ='$country' AND
> province_state ='$stateprovince' AND relationship ='$relationship' ORDER
BY
> signupdate DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2 . " from " . $stateprovince . ", " . $country . "
looking
> for " . $relationship . " relationship.";
>
> }
>
>
> elseif(($country == "All") && ($stateprovince != "All") && ($relationship
!=
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' AND province_state
> ='$stateprovince' AND relationship ='$relationship' ORDER BY signupdate
> DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2 . " from " . $stateprovince . " looking for " .
> $relationship . " relationship.";
>
> }
>
>
> elseif(($country == "All") && ($stateprovince == "All") && ($relationship
!=
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' AND relationship ='$relationship'
> ORDER BY signupdate DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2 . " looking for " . $relationship . " relationship.";
>
> }
>
>
> elseif(($country != "All") && ($stateprovince == "All") && ($relationship
!=
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' AND country ='$country' AND
> relationship ='$relationship' ORDER BY signupdate DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2 . " from " . $country . " looking for " . $relationship
.
> " relationship.";
>
> }
>
>
> elseif(($country == "All") && ($stateprovince != "All") && ($relationship
==
> "All")){
>
> $sql = "SELECT friend_id, first_name, sex, age, city, province_state,
> country, relationship FROM FRIEND WHERE sex = '$sex' AND age BETWEEN
'$age1'
> AND '$age2' AND sexuality ='$sexuality' AND country ='$country' ORDER BY
> signupdate DESC";
> $searchcriteria = $sex . " " . $sexuality . " between the ages of " .
$age1
> . " and " . $age2 . " from " . $stateprovince;
>
> }
>
>
> #connect to db here
>
> odbc_do($connectionToDb, $sql);
>
> blah, blah, blah :)
>
>
>
>
>
>
> "Geoffrey Makstutis" <[EMAIL PROTECTED]> wrote in message
> 002201c1c460$85f5fd80$8eaf7ad5@nt">news:002201c1c460$85f5fd80$8eaf7ad5@nt...
> Hi,
>
> I've got an HTML form which allows users to select various criteria to
> search for in my database (MySQL).
>
> The problem is that I can't seem to figure out how create the SELECT
> statement, given the fact that they could choose any or none of the
> criteria.
>
> Does anyone know of a way to dynamically create a SELECT statement that
> might have different numbers of criteria?
>
> Thanks
>
>
>
>
--- End Message ---
--- Begin Message ---
Might be late, but here's what I have working.
"Troy A. Delagardelle" wrote:
> I am trying to encrypt a credit card number using rc4 and php and then dump
> it into a mySql database. Does anyone have any sample code that allows me
> to do this??
>
> I found the Class.RC4Crypt algorithm and would like to use that. When I
> include the class.rc4crypt.php the page dies...
>
> Here is my code...
>
> // encrypt the credit card number here.
>
> include("class.rc4crypt.php");
>
> $pass = $whatever;
> $data = $cardInfo['number'];
> $case ='de';
$case should be 'en' for encrypting.
> $rc4 = new rc4crypt;
> $encrypt_CC = endecrypt($pass, $data, $case);
Use this:
$rc4 = new rc4crypt;
$encrypt_CC=$rc4->endecrypt($pass, $data, "$case");
$data="encrypted"; // don't leave it in memory
>
>
> then I will send $encrypt_CC to the DB..
>
> Any help would be greatly appreciated..thx Troy
--- End Message ---
--- Begin Message ---
Because of the limitations of MS SQL Server and the inability to limit
result sets as you are in MySQL, I am having to finesse/brute force a method
to peruse through large result sets.
My question is this: How exactly does the mssql_fetch_array() function
work? Does it make a call to the db server for each fetch, or is the entire
result set returned from the db server and stored locally in memory and the
fetch call just pulls it from there?
I suppose it makes little difference in the final design, since I'll need to
have the functionality anyway, I was just curious about what kind of
overhead I'd be creating.
Thanks,
Jeremy
--- End Message ---
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php