[PHP-DB] Re: Dynamic Drop Down Box

2002-03-06 Thread Aron Pilhofer

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
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: multiple select statements

2002-03-06 Thread Aron Pilhofer

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="") {

$query.="";
}

if ($clickbox2="") {
$query.="";
}

then at the end: $query.="from ";

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 :)
>
>
> 
> # 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 f

Re: [PHP-DB] addslashes needed for db security? Hack proving webapps

2002-03-06 Thread Aron Pilhofer

> Paul
>
>  while ($self != "asleep") {
> $sheep_count++;
> }
> ?>

I have nothing useful to add, except that I nearly spit up my morning coffee
laughing at your signature.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Tutorial?

2002-03-04 Thread Aron Pilhofer

Right. I store mine in the same db, and it gets inserted with the other data
from the form. Before inserting, the script does a quick query, selecting
all rows where the unique_id is equal to the current ID. since a new one is
generated for each submit click, the answer will be zero on a proper insert.
On a reload, the answer (mysql_affected_rows) will be 1, so you exit the
script at that point. I also check to make sure the required fields are not
blank before inserting, so that handles the problem of inserting a blank
record if the user clicks twice.

anyway, it works... you can click and click and click all you want, reload
until you're blue in the face, and you'll only get one proper insert. better
yet, not a word of javascript was involved. :)

"Jonathan Hilgeman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> This is another good idea. When reloading the page, have the script
generate
> that unique ID, store it in a separate table AND  put it in a hidden
input.
> When the user submits, the database checks to see if the unique ID is in
the
> database, and if so, the ID is deleted from the database, and the order is
> processed. On subsequent clicks, the unique ID would not be found in that
> database table so the query would fail with a message ("You have clicked
> more than once") or something like that, and the person could check the
> status of an order identified by that unique ID.
>
> - Jonathan
>
> -Original Message-
> From: Aron Pilhofer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 04, 2002 9:51 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Tutorial?
>
>
> The easiest and best solution is to redirect to a new page after the
submit.
> But I have had cases where it was necessary to have the submit code and
the
> form on the same page.
>
> I agree totally with jonathan that a server-side solution is the way to
go.
> To solve the problem (avoid clicking twice and/or reloading the page) I
used
> a hidden field that generated a unique ID based, and then placed that into
a
> field that only accepts unique values. If the user reloads, the query
> fails - trap that error and you're golden.
>
>
> "Jonathan Hilgeman" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> > Hi Jennifer,
> > I'm guessing the purpose of this would be to keep people from
> > double-clicking and submitted information twice, possibly making an
> > application deduct payment twice or something important similar in
nature.
> >
> > The best way I've found of accomplishing the goal of keeping people from
> > clicking twice has three parts:
> > 1) Quickly switching the page. On the next page, have PHP write out
about
> > 300 spaces and a newline, then call the flush() function to make the
> output
> > get sent to the browser. In many cases, this will cause the browser to
> > quickly switch to the next page and display a blank page while the data
> gets
> > processed.
> >
> > 2) It's still remotely possibly to click twice even if you have part 1
in
> > place, so this is a more fool-proof method. Store your data in a
database
> > before processing it - along with a timestamp. When the person clicks
the
> > submit button twice, the program checks the database to see if there is
> the
> > same information with a very close timestamp. If so, update the
timestamp
> in
> > the database. At this point you can choose 3 paths:
> >
> > - Store the data so you can batch-process the data at a later time, once
> you
> > are sure that the visitor has left and there will be no more clicks. For
> > example, have a program that runs every 5 minutes (via cron), then have
> that
> > program check for data/orders that are at least 5 minutes old, and
process
> > them. That means that the timestamp hasn't been updated by extra clicks
in
> 5
> > minutes (and you could still have notified the visitor that their order
or
> > data request is now in line to be processed).
> >
> > - Process the data immediately. If you need to process an order
> immediately
> > and give back results, use the above method, but modify it a bit.
Instead
> of
> > just displaying notification that their order is in line to be
processed,
> > you can submit to another PHP program which sleeps for about 3-4
seconds,
> > then checks the database until there are no clicks for at least 4
seconds,
> > and THEN processes the data, and returns a value to the screen in like
4-5
> > seconds. Both of these methods have similar goals, though - Receive data
> and
> > timestamp it, Wait $Time, Check for timestamp updates, Process when
> 

Re: [PHP-DB] Tutorial?

2002-03-04 Thread Aron Pilhofer

The easiest and best solution is to redirect to a new page after the submit.
But I have had cases where it was necessary to have the submit code and the
form on the same page.

I agree totally with jonathan that a server-side solution is the way to go.
To solve the problem (avoid clicking twice and/or reloading the page) I used
a hidden field that generated a unique ID based, and then placed that into a
field that only accepts unique values. If the user reloads, the query
fails - trap that error and you're golden.


"Jonathan Hilgeman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> Hi Jennifer,
> I'm guessing the purpose of this would be to keep people from
> double-clicking and submitted information twice, possibly making an
> application deduct payment twice or something important similar in nature.
>
> The best way I've found of accomplishing the goal of keeping people from
> clicking twice has three parts:
> 1) Quickly switching the page. On the next page, have PHP write out about
> 300 spaces and a newline, then call the flush() function to make the
output
> get sent to the browser. In many cases, this will cause the browser to
> quickly switch to the next page and display a blank page while the data
gets
> processed.
>
> 2) It's still remotely possibly to click twice even if you have part 1 in
> place, so this is a more fool-proof method. Store your data in a database
> before processing it - along with a timestamp. When the person clicks the
> submit button twice, the program checks the database to see if there is
the
> same information with a very close timestamp. If so, update the timestamp
in
> the database. At this point you can choose 3 paths:
>
> - Store the data so you can batch-process the data at a later time, once
you
> are sure that the visitor has left and there will be no more clicks. For
> example, have a program that runs every 5 minutes (via cron), then have
that
> program check for data/orders that are at least 5 minutes old, and process
> them. That means that the timestamp hasn't been updated by extra clicks in
5
> minutes (and you could still have notified the visitor that their order or
> data request is now in line to be processed).
>
> - Process the data immediately. If you need to process an order
immediately
> and give back results, use the above method, but modify it a bit. Instead
of
> just displaying notification that their order is in line to be processed,
> you can submit to another PHP program which sleeps for about 3-4 seconds,
> then checks the database until there are no clicks for at least 4 seconds,
> and THEN processes the data, and returns a value to the screen in like 4-5
> seconds. Both of these methods have similar goals, though - Receive data
and
> timestamp it, Wait $Time, Check for timestamp updates, Process when
> timestamp is $Time old.
>
> 3) Have a very visible notice that people should not click multiple times,
> or else undesirable results may occur, and we want "your" request/order to
> be perfect. Emphasize the request to click only once and to be patient,
and
> if something goes wrong, here's how to contact us.
>
> - Jonathan
>
> -Original Message-
> From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, March 02, 2002 10:18 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Tutorial?
>
>
> Hi all,
>
> Can anyone point me to a good tutorial on how to disable a submit button
> once clicked?
> preferably in php.
>
> Thanks
> Jennifer Downey
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] optimization (another tack)

2002-03-04 Thread Aron Pilhofer

Messagethanks!
  "Ray Hunter" <[EMAIL PROTECTED]> wrote in message 
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Here is general information on postgres: 
http://www.ca.postgresql.org/docs/aw_pgsql_book/index.html

  Here is an optimization file included:  This was not written by me!!!

  Let me know if you have questions...s
  Ray Hunter

  Firmware Engineer

  ENTERASYS NETWORKS

-Original Message-
From: Aron Pilhofer [mailto:[EMAIL PROTECTED]] 
Sent: Monday, March 04, 2002 9:10 AM
To: Hunter, Ray
Subject: RE: [PHP-DB] optimization (another tack)


That would be great! Thanks.


[Aron Pilhofer] 
 -Original Message-
From: Hunter, Ray [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 11:04 AM
To: 'Aron Pilhofer'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] optimization (another tack)


  If you are using php and a database you can add more memory to the script and 
optimize the database.  I only use postgres databases for all my large data so I can 
let you know how to optimize postgres...




  Ray Hunter 
  Firmware Engineer 

  ENTERASYS NETWORKS 



  -Original Message- 
  From: Aron Pilhofer [mailto:[EMAIL PROTECTED]] 
  Sent: Monday, March 04, 2002 9:02 AM 
  To: [EMAIL PROTECTED] 
  Subject: [PHP-DB] optimization (another tack) 



  Let me try this again more generally. I am trying to optimize a function in PHP 
that handles very large result sets, which are transferred to arrays, and that does 
some extremely heavy lifting in terms of calculations on those arrays. By design, it 
iterates through each possible combination of two result sets, and does some 
calculations on those results. As you can imagine, the numbers get quite large, quite 
fast; sets of 500 by 1000 necessitate a half-million calculations.

  So, short of rewriting this function in C, which I cannot do, are there any 
suggestions for optimizing. For example: 

  1) is there any advantage to caching an array as a local file? 
  2) the script pumps the results of the calculations into a new table.. would it 
be faster to dump it into a local file instead?

  3) is there any advantage to executing the script as a CGI? (does that make 
sense? I don't know if I know the correct jargon here...)

  Any other tips folks have for scripts that handle a lot of calculations would be 
greatly appreciated. 

  Thanks in advance. 




  -- 
  PHP Database Mailing List (http://www.php.net/) 
  To unsubscribe, visit: http://www.php.net/unsub.php 




[PHP-DB] optimization (another tack)

2002-03-04 Thread Aron Pilhofer

Let me try this again more generally. I am trying to optimize a function in
PHP that handles very large result sets, which are transferred to arrays,
and that does some extremely heavy lifting in terms of calculations on those
arrays. By design, it iterates through each possible combination of two
result sets, and does some calculations on those results. As you can
imagine, the numbers get quite large, quite fast; sets of 500 by 1000
necessitate a half-million calculations.

So, short of rewriting this function in C, which I cannot do, are there any
suggestions for optimizing. For example:

1) is there any advantage to caching an array as a local file?
2) the script pumps the results of the calculations into a new table.. would
it be faster to dump it into a local file instead?
3) is there any advantage to executing the script as a CGI? (does that make
sense? I don't know if I know the correct jargon here...)

Any other tips folks have for scripts that handle a lot of calculations
would be greatly appreciated.

Thanks in advance.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] WHERE clause

2002-03-04 Thread Aron Pilhofer

MySQL is very well documented as well. www.mysql.com, click on
documentation.

"Dl Neil" <[EMAIL PROTECTED]> wrote in message
160001c1c356$2f629c40$c200a8c0@jrbrown...">news:160001c1c356$2f629c40$c200a8c0@jrbrown...;
> Jennifer,
>
> > Wondering do I have to have the WHERE clause in a select query?
> > $b=mysql_query( SELECT * FROM my_table) <-can I use something like
> this
> > or do I have to put WHERE in the statement?
>
>
> Hate to answer a question with a question, but what happened when you
> tried typing this query into the MySQL client? (a far faster solution
> than waiting for someone on the list to get back to you!)
>
> RTFM: 6.4.1 SELECT Syntax
>
> SELECT [STRAIGHT_JOIN]
>[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
>[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] [HIGH_PRIORITY]
>[DISTINCT | DISTINCTROW | ALL]
> select_expression,...
> [INTO {OUTFILE | DUMPFILE} 'file_name' export_options]
> [FROM table_references
>   [WHERE where_definition]
>   [GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC],
> ...]
>   [HAVING where_definition]
>   [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC]
> ,...]
>   [LIMIT [offset,] rows]
>   [PROCEDURE procedure_name]
>   [FOR UPDATE | LOCK IN SHARE MODE]]
>
> When you read these 'template' commands in the manual, if the
> word/clause/construct is enclosed in square brackets, eg
>
>   [WHERE where_definition]
>
> then it is optional. Thus the minimalist SELECT statement looks like:
>
> SELECT select_expression,...
>
> which will only work with some scalar expression, eg SELECT 2+2; or
> SELECT month( '2002-03-04' ); so the minimum to work with a table is:
>
> SELECT select_expression,... FROM table_references
>
> and you're bang on the money!
>
> Regards,
> =dn
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Tutorial?

2002-03-03 Thread Aron Pilhofer

Could you not put the form inside an if/else statement? If the button isset,
or if the name equals submit, then show it disabled. Can't think of a lot of
uses for this, unless, I suppose, you want to have a page with lots of forms
on it, and you want to submit pieces of information. It wouldn't prevent
users from reloading the page and creating duplicate records.



"Greg Donald" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> On Sat, 2 Mar 2002, Jennifer Downey wrote:
>
> >Can anyone point me to a good tutorial on how to disable a submit button
> >once clicked?
> >preferably in php.
>
> If you reload the page after the button is clicked then you can simply
> pass a $disable variable in your form as a hidden field, then you can
> check for the variable before drawing the button the second time.
>
> Sounds more like a javascript thing to me though.  PHP is a server side
> scripting language, it's not designed to manipulate forms and buttons,
> where javascript is.
>
> --
> ---
> Greg Donald - http://destiney.com/
> http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/
> ---
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Anyone with suggestions to make this run faster?

2002-03-02 Thread Aron Pilhofer

hey folks,

I just got done writing a function to help with my data cleaning. It works -
actually a lot better than I thought it would - but I am sure there are ways
I could optimize this somewhat. The function takes two result sets (usually
first name, last name, city, state, zip) from two tables, then calculates
the similar_text() value for each pair (first name from table one, versus
first name from table two, and so forth) and places those values into a new
table. What I end up with is a sort of fuzzy matching lookup table, so I
could look up all values where there is a 90 percent match in each category
(for example), and then use that to update my original tables.

Hope that makes sense. Anyway, here's the code. If anyone has any
suggestions (such as, is it faster to dump into a local file and then move
that into a table?), I'm all ears. Thanks in advance:








-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] similar_text() equivalents

2002-03-01 Thread Aron Pilhofer

I do a lot of data cleaning, and I have really grown enamored of the
similar_text() function. Just curious, is there anything directly equivalent
in perl and/or python? Thanks in advance.

aron



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: PHP Question on MySQL grouping

2002-03-01 Thread Aron Pilhofer

depending on how you print the result set to the browser, you just need to
add an echo "" at the end of each line. So, if you've fed your result
set into an array called $row, then something like:

print "$row[0] . $row[1] . $row[2] . "";

That should print out each result followed by a horizontal rule. Something
like that anyway. Hope that helps.



"Keiran Wynyard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> I need to loop through a grouped recordset adding a  at the
> end of each group, how can groups in recordsets be identified in
> PHP for specific formatting.
>
>  SELECT name AS name, dishtype AS dishtype, price AS price
>  FROM dishes
>  WHERE used = 1
>  GROUP BY dishtype, name
>  ORDER BY dishtype, price DESC
>
> The use is in the display of a menu for a restaurant, where there
> is a table containing all the dishes on the menu in any given
> instance, but they musst be displayed in a specific order,
> grouped by type. In other words, all Starters come first,
> followed by Main courses, followed by Desserts. Between each type
> there needs to be a seperator, the horizontal line.
>
>  Thanks for you help
>
> Keiran



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: I'm really stuck!

2002-03-01 Thread Aron Pilhofer

First, could you be more specific? What isn't working? What error messages
are you getting? (I assume you are echoing them, because if not, you should
be... mysql_query($query) or die (mysql_error());

Second, this could be a problem. I think you need single quotes around the
variable here:

$query = "select bin_data, filetype from image_data where
id=---'$id'"; -

Beyond that, I can't really help much. Never stored image data in a db
before, so I can't tell you if anything else might be amiss. Good luck.


"Jennifer Downey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
Hi all,

I'm really stuck and I'm not asking anyone to re-write this just show me
what is wrong, or explain why it wont work. It just seems logical that this
should work.

The first query will print the pet id in the browser.

$query="SELECT  id FROM wt_users WHERE uid={$session["uid"]}";
$ret = mysql_query($query);
while(list($pet)=
mysql_fetch_row($ret))
print("your pet id is $pet");

So if $pet will print the id from the wt_users (has a value of 3) and I
assign $id = $pet (id also has a value of 3 in image_data)  why doesn't it
show the image?

if($id) {


$id = $pet;
$query = "select bin_data,filetype from image_data where id=$id";

  $result = mysql_query($query);

$data = mysql_query($result,0,"bin_data");
$type = mysql_query($result,0,"filetype");

Header( "Content-type: $type");
echo $data;

};
echo "";

Thanks
Jennifer Downey




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Looping through two arrays

2002-02-28 Thread Aron Pilhofer

Jason, you rock! Works perfectly, thanks!

aron

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> On Friday 01 March 2002 01:00, Aron Pilhofer wrote:
>
> [snip]
>
> Try:
>
> > Any help is greatly appreciated. Here's the code:
> >
> > while ($row_new = mysql_fetch_row($res_master))
> >   {
>
> mysql_data_seek($res_new, 0);
>
> >   while ($row_old = mysql_fetch_row($res_new))
> >   {
> >echo($row_new[0] . $row_new[1]);
> >echo($row_old[0] . $row_old[1] . "");
> >   }
> > }
>
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
>
> /*
> Sorry never means having your say to love.
> */



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Join tables

2002-02-28 Thread Aron Pilhofer

Microsoft Access: light-duty relational database with a world-class (in my
opinion) GUI interface, but I don't think it's going to help you in this
case.

> > > id in image_data has the same value as id in wt_users

do you mean uid in wt_users? So, $id=session ID? I might set that ahead of
time just to make it simpler.

Therefore, you really only need one select statement. I'm no expert at this,
and you may need to tweak this a little, but this should work :

select ., . from wt_users,
image_data where $id=wt_users.uid and $id=image_data.id

substitute the table name and field names for .,
obviously. For example, wt_users.uid, image_data.id and so forth. That
should get you on your way.

aron



"Jennifer Downey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> Ok thanks for that info, but I guess I am ignorant to what MS Access is.
> Please enlighten me.
>
>
> Thanks
> Jennifer Downey
>
>
> "Marius Ursache" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> > the best tool for building "join" queries is MS Access .
> >
> > make a db same as that you use in mysql and build the query with access.
> then copy/paste queries from there.
> >
> > to build queries in access is very simple . drag/drop and other visual
> ways.
> >
> >
> > Jennifer Downey a écrit :
> >
> > > Hi all,
> > >
> > > Ok first I have figured out my question on storing an image path.
> > >
> > > my question now is on joining data from two tables.
> > >
> > > wt_users has two fields (cols)  called
> > > uid and pid,
> > > uid refers to the user
> > > pid refers to the users pet
> > >
> > > image_data has a field called
> > > id which refers to the image path
> > >
> > > id in image_data has the same value as id in wt_users
> > > 1  1
> > >
> > > These two queries are what are needed to get the image to display:
> > > $pet = mysql_query("select id from wt_users where
> uid={$session["uid"]}");
> > > $ret = mysql_query($pet);
> > >
> > > $query = "select binary_data,filetype from image_data where id=$id";
> > > $result = @mysql_query($query);
> > >
> > > I'm using echo " with both id's \">"; to display the image
> > >
> > > how do I join the two tables so that the id's match and give the
correct
> image?
> > >
> > > And again thanks in advance for your help
> > > Regards
> > > Jennifer Downey
> > >
> > > P.S. I have looked at the mysql manual and a few tutorials. None of
them
> helped or worked.
> >
> > --
> >   Marius Ursache (3563 || 3494)
> >
> >\|/  \|/
> >"@'/ ,. \`@"
> >/_| \__/ |_\
> >   \__U_/
> >
> >
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Looping through two arrays

2002-02-28 Thread Aron Pilhofer

This one seems like it should be easy, but I can't get anything to work. I
have two tables. I want to pull a first name and last name from each table,
a master table and a new table. Then, I want to list them in a specific way:
I want to list the first name of the master table, then list all the names
from the new table, then i want to move to the second name in the master
table, and list all the names in the new table again, and so forth until I
have listed all combinations.

I have been able to list the first name from the master table, and all the
names from the new table, but the loop stops right there. It won't go to the
second name in the master and relist all the names from the new table. I
suspect I need a "foreach" instead of a "while," but I am just learning the
importance of arrays so I am not real good with the syntax as yet.

Any help is greatly appreciated. Here's the code:

while ($row_new = mysql_fetch_row($res_master))
  {

  while ($row_old = mysql_fetch_row($res_new))
  {
   echo($row_new[0] . $row_new[1]);
   echo($row_old[0] . $row_old[1] . "");
  }
}




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: Sorting the result

2002-02-28 Thread Aron Pilhofer

Not sure I totally understand the question, but I think the answer is no
because your count isn't part of the database, nor is it part of the query.
You're asking MySQL to sort a field that doesn't exist, in other words.

The only way around that is to have MySQL calculate the number of occurances
as part of the actualy SQL statement, and off the top of my head I can't
think of a way to do that. There is not a function (I know of) that works
like substr_count() in SQL.

Maybe someone else has a better answer for you, but that's the best I can
do. sorry!

aron




"Kristjan Kanarik" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> Hi,
>
> I've come across a problem and I'm affraid that I'm lacking the skills of
> writing proper SQL queries in order to solve this. I'm building a little
> search engine for my site (yes, from scratch! It doesn't have to be the
> best, but I think that for my personal use it will be enough) and the bit
> of code I have right now is as follows:
>
> 
> /* I'm using MySQL 3.23.37 together with 4.0.6 on a FreeBSD box */
>
> $article_query = mysql_query("select article_name, article_text from
articles where article_name LIKE '%$q%'") or die (mysql_error());
> /* where $q is the search query with a space added in front */
>
> while ($results = mysql_fetch_array($article_query)) {
>  $art_name = $results["article_name"];
>  $article_text = $results["article_text"];
>  $q_count = substr_count($article_text, "$q");
>  echo "$art_name$article_text";
> }
>
> 
>
> But what I'd like to achieve is that the results would be displayed in a
> way ORDER BY $q_count DESC - the entry with most $q_count would be
> displayed first, next one second etc. I'm sure that there is a way to sort
> the array with PHP, but is it also possible to let the MySQL do the job?
> It would save some CPU power I think... if not, what would be the easiest
> way to do it with PHP?
>
> TIA,
> Kristjan
>
> P.S. Please CC me as well, I am only on the digest.
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: MySQL problem

2002-02-23 Thread Aron Pilhofer

It means there is a problem with your query. I'm not familiar with the
die(1) and die (2) syntax. I'm not sure what that does, but you might try
echoing your error message from the query to see what message you get.

Hope that helps.

"Caleb Walker" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I keep on getting this error statement:
> Warning: Supplied argument is not a valid MySQL result resource in
> /usr/local/www/data/phone/insert2.php on line 10
> 2
>
> Can someone tell me what is wrong with the code below, I just cannot
figure
> it out... Thank you very much in advance.  I am using php4.
>
> 
>  session_start();
> include("info.inc.php");
>
> mysql_connect("$host","$user","$pass") || die(mysql_error());
> mysql_select_db("$db") || die(mysql_error());
>
>
> $q = mysql_query("SELECT FName, LName FROM user_info WHERE (FName='$FName'
&&
> LName='$LName')") || die(1);
> $view = mysql_fetch_array($q) || die(2);
> ?>
>
> 
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] PHP IDE

2002-02-23 Thread Aron Pilhofer

After spending two frustrating hours tracking down a bug yesterday - only to
discover it was a misplaced quote mark. I've had it.

I am looking for suggestions out there for a good IDE for PHP development,
preferably one that doesn't cost an arm and a leg. I tried PHP4EE studio,
but it is buggy as hell and kept crashing on me.

Thanks in advance.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php