Re: [PHP] select * from...

2005-08-09 Thread tg-php
Sounds like you want to do an inner(?) join on the two tables.  This will show 
you where you have matches between the two tables but also show you the items 
that don't match (no special instructions).  If I understand right, you have an 
order_id in both orders and special_orders_instructions right?  You can 
just link on that without needed to add any special columns.  Try something 
like this:


SELECT o.order_id, o.otherordercolumn, soi.order_id,j 
soi.otherinstructioncolumns
FROM orders AS o LEFT JOIN special_orders_instructions AS soi ON o.order_id = 
soi.order_id


Then in PHP just check to see if soi.order_id is blank or not.  If it is, 
there's no special orders to be found.  If it's not blank, then check out the 
SOI variables.


Hope that helped a little.  Forgive any typos... wanted to respond quick so I 
could go home. :)

-TG

= = = Original message = = =

Hi to all,
It's more mysql question than php, but I like you more than mysql guys! :)

Let's say I have a table called orders and other table called 
special_orders_instructions.
Logically, one column in orders table should be link to 
special_order_instructions (foreign key ?) and if that one is checked 
go and grab special instructions after order_id.
But, since orders table doesn't have such a column (and I CANNOT add 
it - long story...) I have to check for every order does that order_id 
exists in special_order_instructions table. And, if yes - print.
Table special_order_instructions has about 25 columns and I have to 
show EVERY ONE. Means, have to use
select * from special_order_instructions...
But, just to check does such an order have any special instruction
$query = mysql_query(select * from special_order_instructions...);
is bad idea. It would be more correct
$query = mysql_query(select spec_inst_id from 
special_order_instructions...);
and then
if (mysql_num_rows($query)  0)

// Show instructions


Does this make a sense:
$query = mysql_query(select spec_inst_id from 
special_order_instructions...);
if (mysql_num_rows($query)  0)

$query = mysql_query(select * from special_order_instructions...);
while( ... )

   // show instructions here...




Thanks for any help!

-afan

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


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

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



Re: [PHP] select from db

2004-06-04 Thread Robert Sossomon
!SNIP
 table name 'Selections'

 (rows)  RoundGameName Winner   Points
   data eg  1 1mark Hawthorn   4
 (if  team is a winner then 4 points added)

1 2mark Geelong 0

! End Snip

Assuming you have them submit a form to get here:
?php
//somefilename

//Access your Database
include db.php;

//Name from previous form, or you can use from authentication,
//whichever, just mod the code to reflect where getting it from
$name = $_POST[name];

//query and results
$query = select * from Selections where Name='$name';
$result = mysql_query($query);

/* Determine the number of records returned */
while ($row = MYSQL_FETCH_ROW($result))
$number = mysql_numrows($result);

/* Start printing to make it look good */
print table cellspacing=\0\ cellpadding=\5\ border=\1\;
print
trthRound/ththGame/ththName/ththWinner/ththPoints/th/tr;

$total_points=0;
/* Iterate through to make it clean */
while ($i  $number)
{
 $item_1 = mysql_result($result, $i,Round);
 $item_2 = mysql_result($result, $i,Game);
 $item_3 = mysql_result($result, $i,Name);
 $item_4 = mysql_result($result, $i,Winner);
 $item_5 = mysql_result($result, $i,Points);

/* This makes it print out in 2 separate color, depending on rows. */
 if ($i%2 == 0)
 {
  print tr
bgcolor=\#ee\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$item_4/tdtd$item_5/td/tr\n;
 }
 else
 {
 print tr
bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$item_4/tdtd$item_5/td/tr\n;
 }
/* Increase record count and total_points to date */
 $i++;
 $total_points += $item_5;
}
/* close everything up */
 print trth colspan=5Total Points Earned: $total_points/th/tr;
 print /table;
}

?

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



Re: [PHP] select from db

2004-06-04 Thread Dennis Seavers
When you run this script, or one like it, does it work?  You seem to be
missing a number of brackets.  For example, you have:

while ($row = MYSQL_FETCH_ROW($result))

instead of 

while ($row = MYSQL_FETCH_ROW($result)) {

or

while ($row = MYSQL_FETCH_ROW($result))
{

 [Original Message]
 From: Robert Sossomon [EMAIL PROTECTED]
 To: BigMark [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Date: 06/03/2004 11:44:58 PM
 Subject: Re: [PHP] select from db

 !SNIP
  table name 'Selections'
 
  (rows)  RoundGameName Winner   Points
data eg  1 1mark Hawthorn   4
  (if  team is a winner then 4 points added)
 
 1 2mark Geelong 0
 
 ! End Snip

 Assuming you have them submit a form to get here:
 ?php
 //somefilename

 //Access your Database
 include db.php;

 //Name from previous form, or you can use from authentication,
 //whichever, just mod the code to reflect where getting it from
 $name = $_POST[name];

 //query and results
 $query = select * from Selections where Name='$name';
 $result = mysql_query($query);

 /* Determine the number of records returned */
 while ($row = MYSQL_FETCH_ROW($result))
 $number = mysql_numrows($result);

 /* Start printing to make it look good */
 print table cellspacing=\0\ cellpadding=\5\ border=\1\;
 print

trthRound/ththGame/ththName/ththWinner/ththPoints/th
/tr;

 $total_points=0;
 /* Iterate through to make it clean */
 while ($i  $number)
 {
  $item_1 = mysql_result($result, $i,Round);
  $item_2 = mysql_result($result, $i,Game);
  $item_3 = mysql_result($result, $i,Name);
  $item_4 = mysql_result($result, $i,Winner);
  $item_5 = mysql_result($result, $i,Points);

 /* This makes it print out in 2 separate color, depending on rows. */
  if ($i%2 == 0)
  {
   print tr

bgcolor=\#ee\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite
m_4/tdtd$item_5/td/tr\n;
  }
  else
  {
  print tr

bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite
m_4/tdtd$item_5/td/tr\n;
  }
 /* Increase record count and total_points to date */
  $i++;
  $total_points += $item_5;
 }
 /* close everything up */
  print trth colspan=5Total Points Earned: $total_points/th/tr;
  print /table;
 }

 ?

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

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



Re: [PHP] select from db

2004-06-04 Thread Dennis Seavers
I think I misread your script.

I took the line

print table cellspacing=\0\ cellpadding=\5\ border=\1\;

to be part of the while loop, meaning there would be two statements.  I'm
not accustomed to seeing scripts that use functions without brackets, even
when their not required.

Sorry for the confusion.


 [Original Message]
 From: Dennis Seavers [EMAIL PROTECTED]
 To: Robert Sossomon [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Date: 06/04/2004 12:00:39 AM
 Subject: Re: [PHP] select from db

 When you run this script, or one like it, does it work?  You seem to be
 missing a number of brackets.  For example, you have:

 while ($row = MYSQL_FETCH_ROW($result))

 instead of 

 while ($row = MYSQL_FETCH_ROW($result)) {

 or

 while ($row = MYSQL_FETCH_ROW($result))
 {

  [Original Message]
  From: Robert Sossomon [EMAIL PROTECTED]
  To: BigMark [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Date: 06/03/2004 11:44:58 PM
  Subject: Re: [PHP] select from db
 
  !SNIP
   table name 'Selections'
  
   (rows)  RoundGameName Winner   Points
 data eg  1 1mark Hawthorn   4
   (if  team is a winner then 4 points added)
  
  1 2mark Geelong   
0
  
  ! End Snip
 
  Assuming you have them submit a form to get here:
  ?php
  //somefilename
 
  //Access your Database
  include db.php;
 
  //Name from previous form, or you can use from authentication,
  //whichever, just mod the code to reflect where getting it from
  $name = $_POST[name];
 
  //query and results
  $query = select * from Selections where Name='$name';
  $result = mysql_query($query);
 
  /* Determine the number of records returned */
  while ($row = MYSQL_FETCH_ROW($result))
  $number = mysql_numrows($result);
 
  /* Start printing to make it look good */
  print table cellspacing=\0\ cellpadding=\5\ border=\1\;
  print
 

trthRound/ththGame/ththName/ththWinner/ththPoints/th
 /tr;
 
  $total_points=0;
  /* Iterate through to make it clean */
  while ($i  $number)
  {
   $item_1 = mysql_result($result, $i,Round);
   $item_2 = mysql_result($result, $i,Game);
   $item_3 = mysql_result($result, $i,Name);
   $item_4 = mysql_result($result, $i,Winner);
   $item_5 = mysql_result($result, $i,Points);
 
  /* This makes it print out in 2 separate color, depending on rows. */
   if ($i%2 == 0)
   {
print tr
 

bgcolor=\#ee\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite
 m_4/tdtd$item_5/td/tr\n;
   }
   else
   {
   print tr
 

bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite
 m_4/tdtd$item_5/td/tr\n;
   }
  /* Increase record count and total_points to date */
   $i++;
   $total_points += $item_5;
  }
  /* close everything up */
   print trth colspan=5Total Points Earned: $total_points/th/tr;
   print /table;
  }
 
  ?
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

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

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread John Nichel
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list

I want to select where like $_POST[var] from a form all of the tables but I
am having trouble :(
I thought making a var string like

$string = table1,table2,table3,.;

And doing

(select * from $string where list like \%$_POST[var]%\);

Would work but I get a MySql error which say Column: 'list' in where clause
is ambiguous
I am stumped so I ask the list for help or advise please.

Any advise is very much appreciated and I thank you in advance for any help
or pointers.
Thank you

Dave C
SELECT * FROM dbname.table1, dbname.table2, dbname.table3, ...etc
WHERE table1.list LIKE '%$_POST['var']%', table2.list LIKE 
'%$_POST['var']%', table2.list LIKE '%$_POST['var']%', ...etc

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread John W. Holmes
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list
The first thing you need to do is reorganize your database schema and 
put all of this into one table. You can see what a pain it is having 24 
similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in 
your query, but I doubt it's going to very efficient. You can't select 
from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 
different times, but you _really_ need to just fix the database 
structure now.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Select from 24 tables

2004-05-01 Thread John Nichel
John W. Holmes wrote:
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list


The first thing you need to do is reorganize your database schema and 
put all of this into one table. You can see what a pain it is having 24 
similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in 
your query, but I doubt it's going to very efficient. You can't select 
from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 
different times, but you _really_ need to just fix the database 
structure now.

Yeah, better what John said than what I said. ;)

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Travis Low
This isn't always desirable, or even possible.  I once designed a database to 
hold characteristics for a series of 70 different tests.  There were about 50 
different characteristics used in various combinations for each test.  Each 
characteristic could be one of many values.  So the characteristics tables all 
looked like this:

  id, name, value

And the test tables looked like this:

  id, name, value

And the mapping of characteristics to test looked like this:

  test_id, characteristic_id

This is actually a gross oversimplification, but you get the idea.  Displaying 
test results typically required joining 30-40 tables together, but since each 
characteristic table was small (10-15 entries), performance was acceptable.

So do as John Nichel first suggested, and do this:

select c1.id as characteristic1_id, c2.id as characteristic2_id from 
characteristic1 c1, characteristic2 c2 etc.

cheers,

Travis

John W. Holmes wrote:
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list


The first thing you need to do is reorganize your database schema and 
put all of this into one table. You can see what a pain it is having 24 
similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in 
your query, but I doubt it's going to very efficient. You can't select 
from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 
different times, but you _really_ need to just fix the database 
structure now.

--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Michal Migurski
 This isn't always desirable, or even possible.  I once designed a
 database to hold characteristics for a series of 70 different tests.
 There were about 50 different characteristics used in various
 combinations for each test.  Each characteristic could be one of many
 values.  So the characteristics tables all looked like this:

id, name, value

 And the test tables looked like this:

id, name, value

In my experience, it's usually a safe assumption that if you have a bunch
of tables all structured identically and used in similar ways, you should
probably merge them all into a single table with an extra column that
corresponds to whatever differentiating characteristic used to distinguish
your original tables.

I.e., go with John Holmes' suggestion before you're really up the creek.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Travis Low
Michal Migurski wrote:
In my experience, it's usually a safe assumption that if you have a bunch
of tables all structured identically and used in similar ways, you should
probably merge them all into a single table with an extra column that
corresponds to whatever differentiating characteristic used to distinguish
your original tables.
I.e., go with John Holmes' suggestion before you're really up the creek.
Up what creek?  You didn't really provide any technical justification for your 
suggestion.

In my experience, the best way to deliver a quality application is to start 
with a fully-normalized database schema, then de-normalize it slightly here and 
there if performance is really a problem.  But I've rarely had to do that.  In 
most cases, an upgrade to a faster server with more memory solves the problem 
more quickly and cheaply than an application re-write would.

On the other hand, I've been called in many times to deal with application 
problems that arise from using mashed-together schemas such as the one you 
propose.

John W. Holmes wrote:
 The first thing you need to do is reorganize your database schema and
 put all of this into one table. You can see what a pain it is having 24
 similar tables already and it's only going to get worse.
The pain only occurs when writing the SQL statements to join the tables.  I 
don't think it's a good idea to optimize the database schema for the sake of 
the programmer, who only has to write the SQL one time.  Later, when the 
customer wants to fix bugs, or add enhancements, the pain is far greater. 
That's usually when I get called in, long after the original programmer has 
flown the coop.

The only times I ever purposely deliver denormalized applications such as you 
suggest are when the customers are asking for quick-and-dirty stopgap 
solutions.  Then it makes sense to optimize for the application writer. 
However, I have found that stopgap solutions have a way of becoming permanent. 
 These days, I usually turn down such jobs.

cheers,

Travis

--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Michal Migurski
 Up what creek?  You didn't really provide any technical justification
 for your suggestion.

Up the creek of having to call for help on php-general because you have 24
identical tables you need to join, having never performed a join before.

 The pain only occurs when writing the SQL statements to join the
 tables.  I don't think it's a good idea to optimize the database schema
 for the sake of the programmer, who only has to write the SQL one time.

I wholeheartedly disagree. :) I think that optimizing for the sake of the
programmer, the bug fixer, and the possible inheritor of the project is a
/great/ idea. Servers keep getting faster, while the human attention span
and rate of familiarization with code stays approximately constant, so
optimizing your development time is at least as sensible as optimizing SQL
select performance, which is probably better handled through well-chosen
indexes anyway.

Optimizing for the programmer usually translates into thinking about the
humans who will need to interpret your code, and making it easy to pick up
the gist of your intent. A 24-table join is not a typical characteristic
of what I'd consider a well-planned DB schema, whose meaning can be
quickly grokked by a newcomer to the project.

If all those 24 tables store the same kind of data, then there's no reason
to split them up. Of course, we haven't seen the specific usage of those
tables in this thread, but I'm basing my posts on the assumption that it's
better for the OP to have a marbles table with a color  column, than
tables named red_marbles, blue_marbles, 'green_marbles,  etc. If
that's not the kind of data we're talking about, then I stand corrected,
and John Nichel's initial response is all that's needed.

A huge table count is often evidence of a need for some refactoring.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Travis Low
Hi Michal,

Getting back to the original posting, I'm basically saying that I don't think 
it's a good idea to structure or restructure a database for the sake of 
simplifying a few SQL statements.  Especially if the data being joined is in 
separate tables for a good reason.

Regarding optimizing for programmer/bug-fixer/etc, after thinking about it, I 
realized that what constitutes optimization really depends a lot on your 
development situation, so I'll refrain from further comments on that.  I 
probably shouldn't have brought it up, sorry.

cheers,

Travis

Michal Migurski wrote:
Up what creek?  You didn't really provide any technical justification
for your suggestion.


Up the creek of having to call for help on php-general because you have 24
identical tables you need to join, having never performed a join before.

The pain only occurs when writing the SQL statements to join the
tables.  I don't think it's a good idea to optimize the database schema
for the sake of the programmer, who only has to write the SQL one time.


I wholeheartedly disagree. :) I think that optimizing for the sake of the
programmer, the bug fixer, and the possible inheritor of the project is a
/great/ idea. Servers keep getting faster, while the human attention span
and rate of familiarization with code stays approximately constant, so
optimizing your development time is at least as sensible as optimizing SQL
select performance, which is probably better handled through well-chosen
indexes anyway.
Optimizing for the programmer usually translates into thinking about the
humans who will need to interpret your code, and making it easy to pick up
the gist of your intent. A 24-table join is not a typical characteristic
of what I'd consider a well-planned DB schema, whose meaning can be
quickly grokked by a newcomer to the project.
If all those 24 tables store the same kind of data, then there's no reason
to split them up. Of course, we haven't seen the specific usage of those
tables in this thread, but I'm basing my posts on the assumption that it's
better for the OP to have a marbles table with a color  column, than
tables named red_marbles, blue_marbles, 'green_marbles,  etc. If
that's not the kind of data we're talking about, then I stand corrected,
and John Nichel's initial response is all that's needed.
A huge table count is often evidence of a need for some refactoring.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html



--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Curt Zirzow
* Thus wrote Travis Low ([EMAIL PROTECTED]):
 Hi Michal,
 
 Getting back to the original posting, I'm basically saying that I don't 
 think it's a good idea to structure or restructure a database for the sake 
 of simplifying a few SQL statements.  Especially if the data being joined 
 is in separate tables for a good reason.

The problem is that we're not talking about normalization in this
case. The OT post is using 24 tables for each letter of the
alphabet (Dont ask me how that number was derived.) So each table
represents the same exact scructure.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



RE: [PHP] select * From ????

2002-12-15 Thread Martin Towell
can you post some more of your code? I think, if it's not too big, the
entire while loops

Martin


-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 16, 2002 9:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP] select * From 


Hi,
Am just a newbie at this and was going great until I have hit this smell
snag.

I am connecting to mysql and all works well there. I query a table
Illustrations ($query = SELECT * FROM Illustrations;), and want to
print the values of two columns (titletext  img)within each row as
the request loops.

Print tdtr$row[titletext]br/td/tr;
Print tdtr$row[img]br/td/tr;

The code inplace seems all ok, but for some reason I am only being
returned the value of titletext and not also the value of img. Am I
to be setting a new value for returning the info within img?? (eg
$row2).

I am sorry if this is hard to understand and also a silly Q, I am two
days into learning this stuff. All I want to do is to return these two
values from within the table. titletext and img. They are both text
fields.

Cheers


  


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

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




RE: [PHP] select * From ????

2002-12-15 Thread Martin Towell
Looks good to me, but as Peter said, see if you really are getting something
in ['img']
try print_r($row) or var_dump($row) to make sure

-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 16, 2002 10:01 AM
To: Martin Towell
Subject: RE: [PHP] select * From 


Here is the display code that I started with.

?php
  
  // Request the text From Illustrations table
  $result = mysql_query(
SELECT * FROM Illustrations);
  if (!$result) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }


  // Display the text of each joke in a paragraph
  while ( $row = mysql_fetch_array($result) ) {
printtdtr$row[titletext]br/td/tr;
printtdtr$row[img]br/td/tr;
  }


?

Not sure why it only displays just the titletext.

-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]] 
Sent: Monday, December 16, 2002 8:47 AM
To: Bruce Levick; [EMAIL PROTECTED]
Subject: RE: [PHP] select * From 


can you post some more of your code? I think, if it's not too big, the
entire while loops

Martin


-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 16, 2002 9:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP] select * From 


Hi,
Am just a newbie at this and was going great until I have hit this smell
snag.

I am connecting to mysql and all works well there. I query a table
Illustrations ($query = SELECT * FROM Illustrations;), and want to
print the values of two columns (titletext  img)within each row as
the request loops.

Print tdtr$row[titletext]br/td/tr;
Print tdtr$row[img]br/td/tr;

The code inplace seems all ok, but for some reason I am only being
returned the value of titletext and not also the value of img. Am I
to be setting a new value for returning the info within img?? (eg
$row2).

I am sorry if this is hard to understand and also a silly Q, I am two
days into learning this stuff. All I want to do is to return these two
values from within the table. titletext and img. They are both text
fields.

Cheers


  


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

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




Re: [PHP] SELECT * FROM

2001-08-29 Thread Jeff Lewis

In your query add ORDER BY field name like date or ID DESC.

That way it will put them in descending order and I do believe that is what
you're looking for :)

Jeff
- Original Message -
From: Tarrant Costelloe [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 29, 2001 10:55 AM
Subject: [PHP] SELECT * FROM


 Hello all,
 I have a designing a website of which people can submit news to, this
works
 fine. Just on the main page I have the following code (snippet);

 ?php
 $db = mysql_connect(localhost, root);
 mysql_select_db(tolkiengossip,$db);
 $result = mysql_query(SELECT * FROM news,$db);
 if ($myrow = mysql_fetch_array($result)) {
   echo table width=100% border=1 color=black cellpadding=3 cellspacing=0
 bordercolor=#66\n;

   do {
 printf(tr bgcolor=#99bTitle:/b %s bBy:/b %s |
 bDate:/b %s /trtrb Article:/b %s/trtrb URL:/b a
href=%s
 target=_blankClick here/a/trbr\n, $myrow[title],
  $myrow[nickname],$myrow[created],$myrow[article],$myrow[link]);

   } while ($myrow = mysql_fetch_array($result));

 echo /font/table\n;

 This again works fine just, the problem is that it always leaves the first
 ever article submitted at the top of the page and the latest go down and
 down etc... I would like to get the latest article to go at the top and
 oldest to the bottom.

 Any help would be gratefully apreciated!

 Kind Regards

 Tarrant Costelloe (Taz)
 Development Department
 ---
 (+44) 01273 852014
 (+44) 07714087114
 --
 Qoute/Saying/Poem of the day:
 Common sense is the collection of prejudices acquired by age eighteen. -
 George Burns
 DISCLAIMER: Any opinions expressed in this email are those of the
individual
 and not necessarily those of insurE-Com Ltd.  (http://www.insur-e.net).
This
 email and any files transmitted with it, including replies and forwarded
 copies (which may contain alterations) subsequently transmitted from
 insurE-com, are confidential and solely for the use of the intended
 recipient. It may contain material protected by attorney-client privilege.
 If you are not the intended recipient or the person responsible for
 delivering to the intended recipient, be advised that you have received
this
 email in error and that any use is strictly prohibited. If you have
received
 this email in error please notify the technical Infrastructure Group by
 telephone on +44 (0)1273 204203 or via mail to [EMAIL PROTECTED],
 including a copy of this message. Please then delete this email and
destroy
 any copies of it.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] SELECT * FROM

2001-08-29 Thread Jon Haworth

Couple of other tips for you.


1. SELECT * is bad unless you really need every field. If you don't, specify
which ones you want - the query will perform better. 

$s = SELECT * FROM News; // bad
$s = SELECT NewsHeadline, NewsTeaser FROM News; // better


2. You appear to be connecting to your database (a) as root and (b) without
a password (although you may have modified the code, so I'm not sure). This
is even worse than SELECT * :-)


Cheers
Jon


-Original Message-
From: Tarrant Costelloe [mailto:[EMAIL PROTECTED]]
Sent: 29 August 2001 15:55
To: '[EMAIL PROTECTED]'
Subject: [PHP] SELECT * FROM


Hello all, 
I have a designing a website of which people can submit news to, this works
fine. Just on the main page I have the following code (snippet);

?php

$db = mysql_connect(localhost, root);
mysql_select_db(tolkiengossip,$db);
$result = mysql_query(SELECT * FROM news,$db);

snip

Any help would be gratefully apreciated!

Kind Regards

Tarrant Costelloe (Taz)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] select * from nmensagem m, nusuario...

2001-03-15 Thread Richard Lynch

 select * from nmensagem m, nusuario u, nprefuser p where
 m.cdpreferencia=p.cdpreferencia and p.flag=1;

 With "m.cdpreferencia=p.cdpreferencia" I should get just the values there
 exists on m.preferencia and p.cdpreferencia?

No, because you have a record for every single nusario, since you don't
restrict any relation between u and m, nor u and p

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]