Re: [PHP-DB] Need a Help!

2005-12-12 Thread tg-php
Couple of things you can do:

1. Drop the song ID and only get the artist information  SELECT 
distinct(Artist) from songtable.  It doesn't look like your SELECT statement 
needs a song, but you include the song ID as $id anyway. Any reason for that or 
can you drop it so you only get artist?

2. Pre-parse the results of your current query so you only get one artist 
and/or compile a list of song ID's while you're at it.  Instead of doing your 
option in the database query result WHILE statement, do it outside:

while (results) {
  $artistinfo[$artist][] = $id;
}

Then:

echo select name='blah';
foreach ($artistinfo as $artist = $songsarr) {
  echo optgroup label='$artist';
  foreach ($songsarr as $songid) {
echo option value='$id'$id or whatever/option;
  }
  echo /optgroup;
}
echo /select;

3. Use a different DB structure.  I prefer this structure myself:

Table ARTISTS:
ArtistID
ArtistName
OtherArtistInfo

Table SONGS:
SongID
ArtistID
OtherSongInfo

Or, instead of having ArtistID, if more than one artist may be linked to a 
song, you can do:
Table xrefArtistsSongs:
ArtistID
SongID

Not sure why you'd want to do that for a song unless you're counting covers of 
songs and want all artists who've covered it to point to the same SongID data.

This way you can:

SELECT * from ARTISTS

for your ARTISTS select box

Then once an artist is selected, do a:

SELECT * from SONGS where ARTISTID = $artistid


Just some ideas.

Forgive the pseudo-code and mixed capitalizations.. I think you get the idea 
I'm trying to convey.

-TG

= = = Original message = = =

I have table and insert data using song_id, that means one artist can have
many song_ids. my question is how can I query distinct artist with his/her
song_id while I will not get duplicate data like duplicate artist?
my code is like this

$content .=form id=\form1\ method=\post\ action=\\
  select name=\Quick\ onchange=\MM_jumpMenu('parent',this,0)\
option value=\#\Select Artist/option;


$result= $db-sql_query(SELECT distinct(artist), id FROM
.$prefix._lyrics order by artist asc);
if ($db-sql_numrows($result)) 
 while($row = $db-sql_fetchrow($result)) 
 extract($row);
 $content .=option value='modules.php
?name=$module_nameamp;file=artistamp;c_id=$id'$artist/option;
   


$content .=/select
/form;

that code is fine except it gives me duplicate artist, so I want get rid off
that duplicate. any help


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-DB] Need some help

2005-05-12 Thread Luis Morales
Why not use a sessions ?

once posted your process form, you can store the final results on
session vars and passing the results to other pages.

Take a look on www.php.net on session topic.

Regards,

Luis Morales


Murray @ PlanetThoughtful wrote:

Sorry but this isn't working.  The variable $ttl_price is a calculation in
my first script.  It stores the value of $Total_Price for all items.  I am
trying to pass that to a new page.  It isn't a form that I'm working with,
do I need to make it a form?  I would greatly appreciate any help you
could
offer.



The $_POST[] superglobal is only available to a page directly following a
page with a form on it, when the form's method set to 'POST'.

Id $ttl_price a single value or an array?

If you are not using a form, you could possibly pass the value on the query
string, then use $_GET[] in your target page to retrieve the value from the
query string. This doesn't require the presence of a form on your
originating page.

Otherwise, you could also use sessions to put the value into a session
cookie and then retrieve it from the target page, using the $_SESSION
superglobal.

How are you moving from the page in which the calculation is done to the
page in which you need the calculation? Ie, do you click on a button, a
link, do you redirect to the page etc?

Much warmth,

Murray 

  


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



Re: [PHP-DB] Need some help

2005-05-11 Thread Mark Cain
run the following line of code in your page.  This will help you not only
with this experience but for a long time to come in the future:

phpinfo();

BTW, I suspect that your problem is that the variable is

$_POST['ttl_price'];

and not

$_POST[$ttl_price];

You will see that in the output of phpinfo();

Mark Cain


- Original Message -
From: ReClMaples [EMAIL PROTECTED]
To: PHP php-db@lists.php.net
Sent: Wednesday, May 11, 2005 3:14 PM
Subject: [PHP-DB] Need some help


 Hello all,

I am having an issue with displaying a variable from another php
script.
 Can you help please?

 Here is the code that I'm using:

 ?php

 $item_ttlprice = $_POST[$ttl_price];
 ?
 html
 body
 Your price is: $
 ?php
 echo $item_ttlprice;
 ?
 body
 /html

 pretty simple I would think but I can't figure out what I'm doing wrong.
 The above is the new script.  Below is the script that the $ttl_price is
 coming from:

 td align=center\$ $item_price br/td
 td align=center$item_qty br/td
 td align=center\$ $total_price/td
 td align=centera
 href=\removefromcart.php?id=$id\remove/a/td
 /tr;
 $ttl_price = $ttl_price + $total_price;


 Can anyone tell me what I'm doing wrong?

 I have tried changing this part:

 ?php

 $item_ttlprice = $_POST[$ttl_price];
 ?

 to $item_ttlprice = $_GET[ttl_price];

 to $item_ttlprice = $_POST['$ttl_price'];

 nothing seems to work.


 Thanks for your help
 -Rich


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



Re: [PHP-DB] Need some help

2005-05-11 Thread Philip Hallstrom
  I am having an issue with displaying a variable from another php script.
Can you help please?
Here is the code that I’m using:
?php
$item_ttlprice = $_POST[$ttl_price];
This should at the very least be:
$item_ttlprice = $_POST[ttl_price];  // remove the last dolalr sign
Also, if youre HTML form's action is GET then you should replace POST with 
GET...



?
html
body
Your price is: $
?php
echo $item_ttlprice;
?
body
/html
pretty simple I would think but I can’t figure out what I’m doing wrong.
The above is the new script.  Below is the script that the $ttl_price is
coming from:
td align=center\$ $item_price br/td
   td align=center$item_qty br/td
   td align=center\$ $total_price/td
   td align=centera
href=\removefromcart.php?id=$id\remove/a/td
   /tr;
$ttl_price = $ttl_price + $total_price;
Can anyone tell me what I’m doing wrong?
I have tried changing this part:
?php
$item_ttlprice = $_POST[$ttl_price];
?
to $item_ttlprice = $_GET[ttl_price];
to $item_ttlprice = $_POST[‘$ttl_price’];
nothing seems to work.
Thanks for your help
-Rich
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] Need some help

2005-05-11 Thread Mark Cain
You could use  a form -- but since this is a db maillist -- maybe you ought
to explore that on one of the other php lists e.g. general.

Mark Cain

- Original Message -
From: ReClMaples [EMAIL PROTECTED]
To: Philip Hallstrom [EMAIL PROTECTED]
Cc: PHP php-db@lists.php.net
Sent: Wednesday, May 11, 2005 6:28 PM
Subject: RE: [PHP-DB] Need some help


 Sorry but this isn't working.  The variable $ttl_price is a calculation in
 my first script.  It stores the value of $Total_Price for all items.  I am
 trying to pass that to a new page.  It isn't a form that I'm working with,
 do I need to make it a form?  I would greatly appreciate any help you
could
 offer.

 Thanks
 -rich

 -Original Message-
 From: Philip Hallstrom [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, May 11, 2005 4:36 PM
 To: ReClMaples
 Cc: PHP
 Subject: Re: [PHP-DB] Need some help

I am having an issue with displaying a variable from another php
script.
  Can you help please?
 
  Here is the code that I'm using:
 
  ?php
 
  $item_ttlprice = $_POST[$ttl_price];

 This should at the very least be:

 $item_ttlprice = $_POST[ttl_price];  // remove the last dolalr sign

 Also, if youre HTML form's action is GET then you should replace POST with
 GET...




  ?
  html
  body
  Your price is: $
  ?php
  echo $item_ttlprice;
  ?
  body
  /html
 
  pretty simple I would think but I can't figure out what I'm doing wrong.
  The above is the new script.  Below is the script that the $ttl_price is
  coming from:
 
  td align=center\$ $item_price br/td
 td align=center$item_qty br/td
 td align=center\$ $total_price/td
 td align=centera
  href=\removefromcart.php?id=$id\remove/a/td
 /tr;
  $ttl_price = $ttl_price + $total_price;
 
 
  Can anyone tell me what I'm doing wrong?
 
  I have tried changing this part:
 
  ?php
 
  $item_ttlprice = $_POST[$ttl_price];
  ?
 
  to $item_ttlprice = $_GET[ttl_price];
 
  to $item_ttlprice = $_POST['$ttl_price'];
 
  nothing seems to work.
 
 
  Thanks for your help
  -Rich
 

 --
 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] Need some HELP

2004-05-10 Thread Ryan Jameson (USA)
It looks like register_globals is off. You'll have to access the
variables in the post array on your second page:

 print INPUT TYPE='hidden' NAME='User_name'
VALUE='$_POST['UserName']';

and so on... Try that first.

 Ryan

-Original Message-
From: Adam Farid [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 10, 2004 12:37 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Need some HELP

Hi,

I am  a new to php. I am using php ver 4.0.3 and MySQL.

I have wrote two files and I'd like to pass some varaibles from first
file to use them in the second file.
but  the values did not displayed in the second file(nothing print out).
and also I want to pass them to anothr file ...  here is what I've wrote
:

 file1.php**
?php
.
$username=A;
$user_num=123;
$user_addres=User Address;

print FORM action='file2.php' method=post;
print input type=submit value='send';
print INPUT TYPE='hidden' NAME='UserName' 
VALUE='$username'\n;
print input type=hidden name=UserNum'
value='$user_num';
print input type=hidden name='Addrress' 
value='$user_addres';
print /td;
print /FORM/tr;

?

** second file file2.php 
?php

?

FORM action='anothrfile.php' method=post table

?
 print INPUT TYPE='hidden' NAME='User_name' VALUE='$UserName';
 print input type=hidden name=User_Num' value='$UserNum';
 print input type=hidden name='User_Addres' value='$Address'; ?

trth align=left Name:/thtd ? print $User_name;
?/td/tr
trth align=left User Number:/thtd  ? print $User_Num;
?/td/tr
trth align=left Address:/th td ? print$User_Addres;
?/td/tr ...
input type=submit value='submit'
/table
/FORM
..


Kind Regrads
Adam
I hope someone  can help me. Thanks

_
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger

--
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] Need some HELP

2004-05-10 Thread Daniel Clark
unless you have Globals turned on, I think you and
$_POST['variable_name_here'] in the second page.


print INPUT TYPE='hidden' NAME='UserName' VALUE='$_POST['username']\n;


 Hi,

 I am  a new to php. I am using php ver 4.0.3 and MySQL.

 I have wrote two files and I'd like to pass some varaibles from first file
 to use them in the second file.
 but  the values did not displayed in the second file(nothing print out).
 and
 also I want to pass them to anothr file ...  here is what I've wrote :

  file1.php**
 ?php
 .
 $username=A;
 $user_num=123;
 $user_addres=User Address;

 print FORM action='file2.php' method=post;
   print input type=submit value='send';
 print INPUT TYPE='hidden' NAME='UserName'
 VALUE='$username'\n;
 print input type=hidden name=UserNum'
 value='$user_num';
 print input type=hidden name='Addrress'
 value='$user_addres';
   print /td;
 print /FORM/tr;
 
 ?

 ** second file file2.php 
 ?php
 
 ?

 FORM action='anothrfile.php' method=post
 table

 ?
  print INPUT TYPE='hidden' NAME='User_name' VALUE='$UserName';
  print input type=hidden name=User_Num' value='$UserNum';
  print input type=hidden name='User_Addres' value='$Address';
 ?

 trth align=left Name:/thtd ? print $User_name; ?/td/tr
 trth align=left User Number:/thtd  ? print $User_Num;
 ?/td/tr
 trth align=left Address:/th td ? print$User_Addres;
 ?/td/tr
 ...
 input type=submit value='submit'
 /table
 /FORM
 ..


 Kind Regrads
 Adam
 I hope someone  can help me. Thanks

 _
 Stay in touch with absent friends - get MSN Messenger
 http://www.msn.co.uk/messenger

 --
 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] Need some HELP (not works)

2004-05-10 Thread Daniel Clark
Is it User_name or UserName?

Also try this string with 'UserName' in single quotes.

print INPUT TYPE=\hidden\ NAME=\User_name\
VALUE=$_POST['UserName']\; 

 I've tried but still does not work.
 when I put the varaibles name between ' '

 I found this error:
 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `T_NUM_STRING'.

 I typed in this way

  print INPUT TYPE='hidden' NAME='User_name'
 VALUE='$_POST[UserName]'; 

 but nothing  a new.

 I have checked  register_globals is on.
 in my first page I used session_start(); and   global $HTTP_SESSION_VARS;
 I dont know if this cause the problem that I had.

 Thanks again and more help please.
 Adam

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



Re: [PHP-DB] Need some HELP (not works)

2004-05-10 Thread jeffrey_n_Dyke



Thanks pepole.

I've tried but still does not work.

when I put the varaibles name between ' '

I found this error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING'.

I typed in this way

 print INPUT TYPE='hidden' NAME='User_name'
VALUE='$_POST[UserName]'; 

This is pre register_global concerns...
try ..
print INPUT TYPE='hidden' NAME='User_name' VALUE='{$_POST[UserName]}';
or
print INPUT TYPE=\hidden\ NAME=\User_name\ VALUE=\{$_POST[UserName]}
\;
for a little better HTML.

HTH
Jeff

_
Use MSN Messenger to send music and pics to your friends
http://www.msn.co.uk/messenger

--
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] Need some HELP (not works)

2004-05-10 Thread Marcjon Louwersheimer



- Original message -
From: Adam Farid [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Mon, 10 May 2004 19:54:51 +
Subject: [PHP-DB] Need some HELP (not works)

Thanks pepole.

I've tried but still does not work.

when I put the varaibles name between ' '

I found this error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or 
`T_NUM_STRING'.

I typed in this way

 print INPUT TYPE='hidden' NAME='User_name' 
VALUE='$_POST[UserName]'; 

but nothing  a new.

I have checked  register_globals is on.
in my first page I used session_start(); and   global $HTTP_SESSION_VARS;
I dont know if this cause the problem that I had.

Thanks again and more help please.
Adam

_
Use MSN Messenger to send music and pics to your friends 
http://www.msn.co.uk/messenger

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


Try using  print INPUT TYPE='hidden' NAME='User_name' 
VALUE='.$_POST[UserName].'; 

Actually, if you're using 4.0.x, you can't use $_POST[UserName]. It was
implemented in 4.1.0.
http://ca.php.net/manual/en/reserved.variables.php#reserved.variables.post
Read about it here.
-- 
  Marcjon

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



Re: [PHP-DB] Need some help please!

2004-02-20 Thread Mikael Grön
Hi.

First of all it's never a good idea to use ? instead of ?php. But  
anyway. Your loss. ;)

You will need to do a refresh of the page to be able to run an insert  
query.
The refresh will need to be made by the JavaScript and since I've  
refused to learn JavaScript, I can't help you with that. Remember also  
that the JS needs to send a variable containing the username to the PHP  
code.

Now, I haven't had enough coffee today, so this is the best I can give  
you:
snip
	?php
		mysql_connect($hostname,$mysqluser,$mysqlpassword);
		$username = $_POST['user']; // What ever your JS will send the  
variable in.
		mysql_query(insert into score (user,date) values (' . $username .  
','.date(Y-m-d).'););
	?
/snip

Also, you might want to parse the username through a few str_replace's  
before you insert.. removing stuff like '' and ''.

Good luck!

Mikael

PS: I apparently sent this the first time using the wrong FROM  
address.. So here it comes again. ;)



On Feb 20, 2004, at 03:16, JeRRy wrote:

Hi,

I have this code, comments below:

? include(../pages/setup.php);?
? login();?
? include(../pages/header.php);?
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01
Transitional//EN
html
head
STYLE
.general3 {background-color:#33;z-index:4}
.general2 {background-color:#55;z-index:3}
.general1 {background-color:#77;z-index:2}
.general0 {background-color:#99;z-index:1}
/STYLE  
title/title
/head
body
?
include(./config.phtml);
include(./$languagefile);
mysql_connect($hostname,$mysqluser,$mysqlpassword);
$query = select * from kras_params;;
$result = mysql_db_query($database,$query);
$row = mysql_fetch_array($result);
//fill vars
$total = $row[kr_total];
$chance = $row[kr_chance];
$maxwins = $row[kr_max_wins];
$wins = $row[kr_wins];
$timesaday = $row[kr_timesaday];
$host = $REMOTE_ADDR;
$check = 1;
$q_checktimes = select count(*) from kras_users where
usr_ip='$host' and usr_date=CURDATE();;
$checktimes_result =
mysql_db_query($database,$q_checktimes);
$times = mysql_fetch_row($checktimes_result);
$error = ;
if ($times[0]  $timesaday) {
//poging toevoegen in database
$raisetimes = insert into kras_users
values('$host',CURDATE(),'$HTTP_SESSION_VARS[username]');;
$raiseresult = mysql_db_query($database,$raisetimes)
or die('error: raise times failed');
} else {
$error .= LI$txt_maxplay $timesaday.;
$check = 0;
}
if ($wins == $maxwins) {
$error = LI$txt_maxwon;
$check = 0;
}
if ($check) {
//aantal malen dat spel gespeeld is ophogen met 1
$raisetotal = update kras_params set
kr_total=(kr_total+1);;
$raiseresult = mysql_db_query($database,$raisetotal);

if ($total%$chance == 0) {
$raisewins = update kras_params set
kr_wins=(kr_wins+1);;
$raisewinsresult =
mysql_db_query($database,$raisewins) or die('error:
raise wins failed');
$winner = 1;
}

?
	SCRIPT
	sc=new
Array('gfx/crown.jpg','gfx/x.jpg','gfx/seven.jpg','gfx/ 
diamond.jpg','gfx/ruby.jpg','gfx/magic.jpg');
	z=new Array();
	
	function check() {
		var oDivs = document.all.tags(DIV);
		for (i=0; ioDivs.length; i++){	
			
			var scratched = true;
			if (oDivs(i).style.display != none 
oDivs(i).scratchable == true) {
scratched = false;
return false;
			}
		}
		if (scratched == true)  {

?

echo ($winner ? alert(\$txt_youwon!
$HTTP_SESSION_VARS[username]\) :
alert(\$txt_youlost\));
			?

		}
	}	
			
	function rnd() {
		return Math.floor(Math.random()*sc.length);
	}
	
	?
	if ($winner) {
		echo function scimgload() {;
		echo document.scratch1.src=sc[rnd()];;
		echo document.scratch2.src=document.scratch1.src;;
		echo document.scratch3.src=document.scratch1.src;;
		echo };
	} else {
		echo function scimgload() {;
		echo document.scratch1.src=sc[rnd()];;
		echo document.scratch2.src=sc[rnd()];;
		echo document.scratch3.src=sc[rnd()];;
		echo while (document.scratch2.src ==
document.scratch3.src) {;
		echo document.scratch3.src=sc[rnd()];;
		echo };
		echo };
	}
	?
	function scmetal() {
	for (i=0;i192;i++)
	document.all['M'+i].style.display=;
	}
	/SCRIPT
	
	SCRIPT FOR=window EVENT=onload LANGUAGE=JScript
	  scimgload();
	/SCRIPT
	
	h1centerfont color=blueTMC Scratch n
Match/font/H1
	
	DIV scratchable=false STYLE=position:
relative;height: 300
	
	SCRIPT
	// This script must be within the relatively
positioned DIV.
	for (p=0;p3;p++)
	for (i=0;i4;i++)
	for (j=0;j4;j++)
	for (k=0;k4;k++) {
	idn=p*64+i*16+j*4+k;
	document.write('DIV scratchable=true ID=M'+idn+'
onmouseover=style.display=\'none\';check();
CLASS=general'+i+'
STYLE=position:absolute;width:25;height:25;top:'+eval(0+j*25)+'; 
left:'+eval(125+p*125+k*25)+'/DIV');
	}
	/SCRIPT
	IMG SRC= NAME=scratch1 ID=img1
STYLE=position:absolute;top:0;left:125;width:100;height:100;z-index: 
0
	IMG SRC= NAME=scratch2 ID=img2
STYLE=position:absolute;top:0;left:250;width:100;height:100;z-index: 
0
	IMG SRC= 

Re: [PHP-DB] Need some help please!

2004-02-20 Thread JeRRy
Mikael,

Hi :)

 First of all it's never a good idea to use ?
 instead of ?php. But  
 anyway. Your loss. ;)

My loss?  Explain?  (all ears)  I've used only ? php
a few times and end it with ? ...  But I normally use
only ? and ? and have *never* had a problem with it.
 

But I am all ears knowing why though?  I have seen
alot of different ones but have no idea what they mean
to be totally honest, here are some.

Starting codes:

?
? php 
? php else:
? php4 // I am guessing for php4 but could be wrong
//

 You will need to do a refresh of the page to be able
 to run an insert  
 query.
 The refresh will need to be made by the JavaScript
 and since I've  
 refused to learn JavaScript, I can't help you with
 that. Remember also  
 that the JS needs to send a variable containing the
 username to the PHP  
 code.

Bugger, can anyone else assist me here, the query part
I know how to do.  Just need help refreshing maybe to
the same file but use a if extension like this:

samefile.php?winner=WINNER CODE GOES HERE

WINNER CODE I could generate automatically when a game
is done, so if a winner it will update to the db with
the winner code and where someone hits the above page
it will look for that code again, if can't find it
will not generate the credits.  If it's found it will.

 Now, I haven't had enough coffee today, so this is
 the best I can give  
 you:

I've had none . :P  (yet!)

 Also, you might want to parse the username through a
 few str_replace's  
 before you insert.. removing stuff like '' and ''.

Actually I grab the username from a session in the
setup.php file. :)  So I can grab it quite easily.

 Good luck!

Thanks. :)

 PS: I apparently sent this the first time using the
 wrong FROM  
 address.. So here it comes again. ;)

Your not alone, happened to me also. ;)

Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

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



Re: [PHP-DB] Need SQL Help

2004-02-12 Thread John W. Holmes
From: J. Kevin C. Burton [EMAIL PROTECTED]

 I have a SQL statement that looks like this:
 SELECT EMPLOYEENAME,SUPERVISORID WHERE EMPLOYEEID='$employeeid'

 what I want to do is lookup the supervisor's name in the same SQL
 statement. If not, I would have to use an function, and if I have a 100
 employee's in the list, that takes an enormous  amount of time if I have
 to load that function every row.

 Is there a way to do it all in the same 1 SQL statement?

Is this a Parent-Child type relationship, where the supervisor ID is
actually just another employee ID in the same table? If so, you could do it
like this:

SELECT t1.employeename, t1.supervisorid, t2.employeename as supervisorname
FROM employees t1, employees t2 WHERE t1.supervisorid = t2.employeeid NAD
employeeid = '$employeeid'

If that's not your table structure, then you'll have to tell us what it is.

---John Holmes...

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



Re: [PHP-DB] need some help...

2002-04-02 Thread szii

Not really a database question, but why not...

Step 1:  Clean up the code...
 a)  Convert all double-quote to single quotes in the HTML portion.
  I usually use doubles for PHP and singles for HTML.  I hate 
  having to escape quotes.
 b)  Use of spacing and indentation.

old
**
  div align=left
table border=0 cellpadding=0 cellspacing=0 width=95%
  tr
td width=100%p
  font face=Tahoma, Verdana, Arial, Helvetica size=1img
src=/images/menu-reviews.gif width=137 height=20brbr?php
$db = mysql_connect( db,  **,  **);
mysql_select_db( net3dual_reviews,$db);
$r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
$max = mysql_query(select max(num) from hwureviews,$db);
while($a=mysql_fetch_array($r)) {
printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
border=\0\/abrnbsp;nbsp;- a
href=\%s\%s/abrbr,$a[url],$a[picurl],$a[picurl],$a[title])
;
}
?
/font/p
/td
  /tr
/table
  /div
**



new
**
  div align='left'
table border='0' cellpadding='0' cellspacing='0' width='95%'
  tr
td width='100%'p
  font face='Tahoma, Verdana, Arial, Helvetica' size='1'
  img src='/images/menu-reviews.gif' width='137' height='20'brbr
?php
$db = mysql_connect( 'db,  **,  **);
mysql_select_db( net3dual_reviews,$db);
$r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
$max = mysql_query(select max(num) from hwureviews,$db);
while($a=mysql_fetch_array($r))
{
  printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
  border='0'/abrnbsp;nbsp;- 
  a 
href='%s'%s/abrbr,$a[url],$a[picurl],$a[picurl],$a[title]);
}
?
/font/p
/td
  /tr
/table
  /div
**

Since you have to put a string value, assign all output to a single string called 
$output.
Note that I moved your printf() to an echo, and simplified your output string by 
preassigning
variables.  An extra step, but greatly enhances readability and maintenance...
Also remember that the .= is an append operator whereas = is assignment.

even newer
**
 // Assign the stuff before...
 $output =

  div align='left'
table border='0' cellpadding='0' cellspacing='0' width='95%'
  tr
td width='100%'p
  font face='Tahoma, Verdana, Arial, Helvetica' size='1'
  img src='/images/menu-reviews.gif' width='137' height='20'brbr
 ;
?php
$db = mysql_connect( 'db,  **,  **);
mysql_select_db( net3dual_reviews,$db);
$r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
$max = mysql_query(select max(num) from hwureviews,$db);
while($a=mysql_fetch_array($r))
{
  $url = $a[url];
  $picurl = $a[picurl];
  $title = $a[title];

  // add in each link to the review
  $output .= nbsp;nbsp;nbsp;nbsp;
  a href='$url'
 img src='$picurl' border='0'
  /a
  brnbsp;nbsp;- 
  a href='$picurl'
  $title
  /a
  brbr;
}
?
  // finish the structure HTML
  $output .= 
/font/p
/td
  /tr
/table
  /div
;

// Now fopen() the file, fputs the $output, and fclose() the file.
**
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.fputs.php
http://www.php.net/manual/en/function.fclose.php

Party on!

-Szii


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




RE: [PHP-DB] need some help...

2002-04-02 Thread Jonathan Hilgeman

Thank you. Someone else exists who has the sense of mind to use single
quotes. I hate looking at other people's code that has tons of \s in it.

- Jonathan

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 5:00 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] need some help...


Not really a database question, but why not...

Step 1:  Clean up the code...
 a)  Convert all double-quote to single quotes in the HTML portion.
  I usually use doubles for PHP and singles for HTML.  I hate 
  having to escape quotes.
 b)  Use of spacing and indentation.

old
**
  div align=left
table border=0 cellpadding=0 cellspacing=0 width=95%
  tr
td width=100%p
  font face=Tahoma, Verdana, Arial, Helvetica size=1img
src=/images/menu-reviews.gif width=137 height=20brbr?php
$db = mysql_connect( db,  **,  **);
mysql_select_db( net3dual_reviews,$db);
$r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
$max = mysql_query(select max(num) from hwureviews,$db);
while($a=mysql_fetch_array($r)) {
printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
border=\0\/abrnbsp;nbsp;- a
href=\%s\%s/abrbr,$a[url],$a[picurl],$a[picurl],$a[title])
;
}
?
/font/p
/td
  /tr
/table
  /div
**



new
**
  div align='left'
table border='0' cellpadding='0' cellspacing='0' width='95%'
  tr
td width='100%'p
  font face='Tahoma, Verdana, Arial, Helvetica' size='1'
  img src='/images/menu-reviews.gif' width='137'
height='20'brbr
?php
$db = mysql_connect( 'db,  **,  **);
mysql_select_db( net3dual_reviews,$db);
$r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
$max = mysql_query(select max(num) from hwureviews,$db);
while($a=mysql_fetch_array($r))
{
  printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
  border='0'/abrnbsp;nbsp;- 
  a
href='%s'%s/abrbr,$a[url],$a[picurl],$a[picurl],$a[title]);
}
?
/font/p
/td
  /tr
/table
  /div
**

Since you have to put a string value, assign all output to a single string
called $output.
Note that I moved your printf() to an echo, and simplified your output
string by preassigning
variables.  An extra step, but greatly enhances readability and
maintenance...
Also remember that the .= is an append operator whereas = is assignment.

even newer
**
 // Assign the stuff before...
 $output =

  div align='left'
table border='0' cellpadding='0' cellspacing='0' width='95%'
  tr
td width='100%'p
  font face='Tahoma, Verdana, Arial, Helvetica' size='1'
  img src='/images/menu-reviews.gif' width='137'
height='20'brbr
 ;
?php
$db = mysql_connect( 'db,  **,  **);
mysql_select_db( net3dual_reviews,$db);
$r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
$max = mysql_query(select max(num) from hwureviews,$db);
while($a=mysql_fetch_array($r))
{
  $url = $a[url];
  $picurl = $a[picurl];
  $title = $a[title];

  // add in each link to the review
  $output .= nbsp;nbsp;nbsp;nbsp;
  a href='$url'
 img src='$picurl' border='0'
  /a
  brnbsp;nbsp;- 
  a href='$picurl'
  $title
  /a
  brbr;
}
?
  // finish the structure HTML
  $output .= 
/font/p
/td
  /tr
/table
  /div
;

// Now fopen() the file, fputs the $output, and fclose() the file.
**
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.fputs.php
http://www.php.net/manual/en/function.fclose.php

Party on!

-Szii


-- 
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] need some help...

2002-04-02 Thread Shrock, Court

If you want your output to validate xhtml, you had better make sure that
your html looks like:

a href=link.phpLink/a

and NOT:

a href='link.php'Link/a



 -Original Message-
 From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 02, 2002 4:52 PM
 To: '[EMAIL PROTECTED]'
 Cc: '[EMAIL PROTECTED]'
 Subject: RE: [PHP-DB] need some help...
 
 
 Thank you. Someone else exists who has the sense of mind to use single
 quotes. I hate looking at other people's code that has tons 
 of \s in it.
 
 - Jonathan
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 02, 2002 5:00 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] need some help...
 
 
 Not really a database question, but why not...
 
 Step 1:  Clean up the code...
  a)  Convert all double-quote to single quotes in the 
 HTML portion.
   I usually use doubles for PHP and singles for 
 HTML.  I hate 
   having to escape quotes.
  b)  Use of spacing and indentation.
 
 old
 **
   div align=left
 table border=0 cellpadding=0 cellspacing=0 width=95%
   tr
 td width=100%p
   font face=Tahoma, Verdana, Arial, Helvetica 
 size=1img
 src=/images/menu-reviews.gif width=137 height=20brbr?php
 $db = mysql_connect( db,  **,  **);
 mysql_select_db( net3dual_reviews,$db);
 $r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC 
 LIMIT 7);
 $max = mysql_query(select max(num) from hwureviews,$db);
 while($a=mysql_fetch_array($r)) {
 printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
 border=\0\/abrnbsp;nbsp;- a
 href=\%s\%s/abrbr,$a[url],$a[picurl],$a[picurl
 ],$a[title])
 ;
 }
 ?
 /font/p
 /td
   /tr
 /table
   /div
 **
 
 
 
 new
 **
   div align='left'
 table border='0' cellpadding='0' cellspacing='0' width='95%'
   tr
 td width='100%'p
   font face='Tahoma, Verdana, Arial, Helvetica' size='1'
   img src='/images/menu-reviews.gif' width='137'
 height='20'brbr
 ?php
 $db = mysql_connect( 'db,  **,  **);
 mysql_select_db( net3dual_reviews,$db);
 $r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC 
 LIMIT 7);
 $max = mysql_query(select max(num) from hwureviews,$db);
 while($a=mysql_fetch_array($r))
 {
   printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
   border='0'/abrnbsp;nbsp;- 
   a
 href='%s'%s/abrbr,$a[url],$a[picurl],$a[picurl],
 $a[title]);
 }
 ?
 /font/p
 /td
   /tr
 /table
   /div
 **
 
 Since you have to put a string value, assign all output to a 
 single string
 called $output.
 Note that I moved your printf() to an echo, and simplified your output
 string by preassigning
 variables.  An extra step, but greatly enhances readability and
 maintenance...
 Also remember that the .= is an append operator whereas = 
 is assignment.
 
 even newer
 **
  // Assign the stuff before...
  $output =
 
   div align='left'
 table border='0' cellpadding='0' cellspacing='0' width='95%'
   tr
 td width='100%'p
   font face='Tahoma, Verdana, Arial, Helvetica' size='1'
   img src='/images/menu-reviews.gif' width='137'
 height='20'brbr
  ;
 ?php
 $db = mysql_connect( 'db,  **,  **);
 mysql_select_db( net3dual_reviews,$db);
 $r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC 
 LIMIT 7);
 $max = mysql_query(select max(num) from hwureviews,$db);
 while($a=mysql_fetch_array($r))
 {
   $url = $a[url];
   $picurl = $a[picurl];
   $title = $a[title];
 
   // add in each link to the review
   $output .= nbsp;nbsp;nbsp;nbsp;
   a href='$url'
  img src='$picurl' border='0'
   /a
   brnbsp;nbsp;- 
   a href='$picurl'
   $title
   /a
   brbr;
 }
 ?
   // finish the structure HTML
   $output .= 
 /font/p
 /td
   /tr
 /table
   /div
 ;
 
 // Now fopen() the file, fputs the $output, and fclose() the file.
 **
 http://www.php.net/manual/en/function.fopen.php
 http://www.php.net/manual/en/function.fputs.php
 http://www.php.net/manual/en/function.fclose.php
 
 Party on!
 
 -Szii
 
 
 -- 
 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
 

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




Re: [PHP-DB] need some help...

2002-04-02 Thread Alex Behrens

Awesome, thanks a ton!

Thanks!

-Alex Big Al Behrens
E-mail: [EMAIL PROTECTED]
Urgent E-mail: [EMAIL PROTECTED] (Please be brief!)
Phone: 651-482-8779
Cell: 651-329-4187
Fax: 651-482-1391
ICQ: 3969599
Owner of the 3D-Unlimited Network:
http://www.3d-unlimited.com
Send News:
[EMAIL PROTECTED]
- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 02, 2002 7:00 PM
Subject: Re: [PHP-DB] need some help...


 Not really a database question, but why not...

 Step 1:  Clean up the code...
  a)  Convert all double-quote to single quotes in the HTML
portion.
   I usually use doubles for PHP and singles for HTML.  I hate
   having to escape quotes.
  b)  Use of spacing and indentation.

 old
 **
   div align=left
 table border=0 cellpadding=0 cellspacing=0 width=95%
   tr
 td width=100%p
   font face=Tahoma, Verdana, Arial, Helvetica size=1img
 src=/images/menu-reviews.gif width=137 height=20brbr?php
 $db = mysql_connect( db,  **,  **);
 mysql_select_db( net3dual_reviews,$db);
 $r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
 $max = mysql_query(select max(num) from hwureviews,$db);
 while($a=mysql_fetch_array($r)) {
 printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
 border=\0\/abrnbsp;nbsp;- a

href=\%s\%s/abrbr,$a[url],$a[picurl],$a[picurl],$a[title])
 ;
 }
 ?
 /font/p
 /td
   /tr
 /table
   /div
 **



 new
 **
   div align='left'
 table border='0' cellpadding='0' cellspacing='0' width='95%'
   tr
 td width='100%'p
   font face='Tahoma, Verdana, Arial, Helvetica' size='1'
   img src='/images/menu-reviews.gif' width='137'
height='20'brbr
 ?php
 $db = mysql_connect( 'db,  **,  **);
 mysql_select_db( net3dual_reviews,$db);
 $r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
 $max = mysql_query(select max(num) from hwureviews,$db);
 while($a=mysql_fetch_array($r))
 {
   printf (nbsp;nbsp;nbsp;nbsp;a href=\%s\img src=\%s\
   border='0'/abrnbsp;nbsp;-
   a
href='%s'%s/abrbr,$a[url],$a[picurl],$a[picurl],$a[title]);
 }
 ?
 /font/p
 /td
   /tr
 /table
   /div
 **

 Since you have to put a string value, assign all output to a single string
called $output.
 Note that I moved your printf() to an echo, and simplified your output
string by preassigning
 variables.  An extra step, but greatly enhances readability and
maintenance...
 Also remember that the .= is an append operator whereas = is
assignment.

 even newer
 **
  // Assign the stuff before...
  $output =
 
   div align='left'
 table border='0' cellpadding='0' cellspacing='0' width='95%'
   tr
 td width='100%'p
   font face='Tahoma, Verdana, Arial, Helvetica' size='1'
   img src='/images/menu-reviews.gif' width='137'
height='20'brbr
  ;
 ?php
 $db = mysql_connect( 'db,  **,  **);
 mysql_select_db( net3dual_reviews,$db);
 $r = mysql_query(SELECT * FROM hwureviews ORDER BY num DESC LIMIT 7);
 $max = mysql_query(select max(num) from hwureviews,$db);
 while($a=mysql_fetch_array($r))
 {
   $url = $a[url];
   $picurl = $a[picurl];
   $title = $a[title];

   // add in each link to the review
   $output .= nbsp;nbsp;nbsp;nbsp;
   a href='$url'
  img src='$picurl' border='0'
   /a
   brnbsp;nbsp;-
   a href='$picurl'
   $title
   /a
   brbr;
 }
 ?
   // finish the structure HTML
   $output .= 
 /font/p
 /td
   /tr
 /table
   /div
 ;

 // Now fopen() the file, fputs the $output, and fclose() the file.
 **
 http://www.php.net/manual/en/function.fopen.php
 http://www.php.net/manual/en/function.fputs.php
 http://www.php.net/manual/en/function.fclose.php

 Party on!

 -Szii


 --
 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