[PHP-DB] select from two tables

2002-07-27 Thread Barry Rumsey

I have the following code:
$query = SELECT * FROM xoops_album,xoops_artist WHERE
xoops_album.artist_id = xoops_artist.artist_id; 
 $albumby = mysql_query($query) or die(Select Failed!);
 
echotdcenter;
if (mysql_num_rows($albumr)) {
while ($album = mysql_fetch_array($albumr))
{ 
echo ($album[album]);
echoi by ; echo ($albumby[xoops_artist.artist]); echoibr;
}
   echo /center/td;
}
What I'm trying to do is select the album title from one table ( this
works ok ) and get the artist name from another table ( this is the part
I can't get to work ).  I believe it has something to do with the code
above as the rest works ok. The result I end up with is below:
 
Waterloo by ( this is where I want to put the artist name)
 
 
Thanks for in help in advance.



RE: [PHP-DB] select from two tables

2002-07-27 Thread Barry Rumsey

Ok I tired this but it did not help, but thank you.

-Original Message-
From: Herman Verkade [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, 28 July 2002 1:18 a.m.
To: 'Barry Rumsey'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] select from two tables


Well, I'm just a beginner myself, but I would say that:

 echoi by ; echo ($albumby[xoops_artist.artist]); echoibr;

should at least be:

 echoi by ; echo ($album[xoops_artist.artist]); echoibr;

or even:

 echoi by ; echo ($album[artist]); echoibr;

Hope this helps,

Herman


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




[PHP-DB] multiple inserts

2002-04-20 Thread Barry Rumsey

I have the following insert :
mysql_connect( localhost, ,  );
  mysql_select_db(  );

  mysql_query(INSERT INTO music_album VALUES
(NULL, '$artist_id' ,'$album' ,NULL ,NULL));

  mysql_query(INSERT INTO music_songs VALUES 
(NULL ,NULL ,NULL ,NULL ,'$songname' ,'$lyrics'));

When I run this, the first insert works alright but the second insert 
does nothing. What am I doing wrong ?
 How do I do a mysql_insert_id()?



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




Re: [PHP-DB] drop list inserts

2002-04-18 Thread Barry Rumsey

Yes I see what I have done wrong. I named it music_artist instead of 
nameing it music_artist.id

Sorry about that but thanks for the help. I think I'll need more help as 
I'm still learning.

-Original Message-
From: Christian Schneider [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]
Date: Thu, 18 Apr 2002 12:17:34 +0200
Subject: Re: [PHP-DB] drop list inserts

 Hi Barry,
 
 Barry Rumsey wrote:
$query_id = mysql_query(INSERT INTO music_album VALUES
  (NULL, '$music_artist.id' ,'$album' ,NULL ,NULL));
echo  $artist_name and $album has been added to the 
  
  Could someone please point out what I'm doing wrong?
  
 
 is the value of $music_artist.id correct? Also, your select has the 
 name of music_artist and the value of the respective id, isn't that 
 what you want?
 
 
 Regards,
 
 Christian
 
 
 -- 
 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-DB] drop list inserts

2002-04-17 Thread Barry Rumsey

I have the following to pages( just testing them at the moment ):
? mysql_connect(host,,);
mysql_select_db(music);
echo form name='add_album' method='post' action='test-album-add.php';
$getlist = mysql_query(SELECT * FROM music_artist ORDER BY 
artist_name ASC);
echo  Artist Name : select name=\artist_name\\n;
while ($row = mysql_fetch_array($getlist)) {
echo 'option value='.$row[id].''.$row[artist_name]./option\n;
}
echo  /select\n;
echo brAlbum Name : input type='text' name='album' value='$album';
echo input type='submit' name='Submit' value='Submit';
echo /form;
?

and

?
include(../mainfile.php);
include(../header.php);
OpenTable();

  mysql_connect( host, ,  );
  mysql_select_db( xoops );

  $query_id = mysql_query(INSERT INTO music_album VALUES
(NULL, '$music_artist.id' ,'$album' ,NULL ,NULL));
  echo  $artist_name and $album has been added to the 
database.;
CloseTable();
include(../footer.php);
?

What I am trying to do is insert the id of the artist they selected in 
the first page into a second table. At the moment all I get is 0 
inserted instead of the artist id from page 1.

Could someone please point out what I'm doing wrong?

Thanks in advance.



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




RE: [PHP-DB] drop list inserts

2002-04-17 Thread Barry Rumsey

The $music_artist.id is the id from the first page. ( database = music , 
table = music_artist  id ). This is what I need, a drop down list of the 
artists in table 'music_artist'( I've got this), I want the id of the 
artist they selected in the drop list to be inserted into the 
table 'music_album' as $artist_id.

-Original Message-
From: Gurhan Ozen [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED], php-db list php-
[EMAIL PROTECTED]
Date: Wed, 17 Apr 2002 19:02:52 -0400
Subject: RE: [PHP-DB] drop list inserts

 Hi Barry,
 First of all,
 $query_id = mysql_query(INSERT INTO...);  is wrong. That line will
 just
 assign the resultset of the whatever mysql_query() function returns to
 the
 variable $query_id .. Get rid of $query_id and just have
 mysql_query(INSERt
 INTO ); See: http://www.php.net/manual/en/function.mysql-query.php 
 for
 this..
 Second of all, in your INSERT INTO query you are trying to insert the
 value
 of a variable called $music_artist.id which doesn't exist anywhere. I
 think
 you meant to insert $artist_name instead???
 
 Gurhan
 
 
 -Original Message-
 From: Barry Rumsey [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 17, 2002 6:23 PM
 To: php-db list
 Subject: [PHP-DB] drop list inserts
 
 
 I have the following to pages( just testing them at the moment ):
 ? mysql_connect(host,,);
 mysql_select_db(music);
 echo form name='add_album' method='post'
 action='test-album-add.php';
 $getlist = mysql_query(SELECT * FROM music_artist ORDER BY
 artist_name ASC);
 echo  Artist Name : select name=\artist_name\\n;
 while ($row = mysql_fetch_array($getlist)) {
 echo 'option
 value='.$row[id].''.$row[artist_name]./option\n;
 }
 echo  /select\n;
 echo brAlbum Name : input type='text' name='album'
 value='$album';
 echo input type='submit' name='Submit' value='Submit';
 echo /form;
 ?
 
 and
 
 ?
 include(../mainfile.php);
 include(../header.php);
 OpenTable();
 
   mysql_connect( host, ,  );
   mysql_select_db( xoops );
 
   $query_id = mysql_query(INSERT INTO music_album VALUES
 (NULL, '$music_artist.id' ,'$album' ,NULL ,NULL));
 echo  $artist_name and $album has been added to the
 database.;
 CloseTable();
 include(../footer.php);
 ?
 
 What I am trying to do is insert the id of the artist they selected in
 the first page into a second table. At the moment all I get is 0
 inserted instead of the artist id from page 1.
 
 Could someone please point out what I'm doing wrong?
 
 Thanks in advance.
 
 
 
 --
 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




[PHP-DB] Tutorials

2002-04-16 Thread Barry Rumsey

Are there any good tutorials for beginners on forms and inserts into 
mulit-tables ?



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




[PHP-DB] database table layout help

2002-04-15 Thread Barry Rumsey

I am setting up a music info site and have decided on the follow tables 
( not to sure weather to add the mp3 part). The one main question I have 
before starting to make the tables is weather mysql_insert_id() would be 
able to handle this with the way I have it ?
:Artist
id
artist_name

:Album
id - auto-inc
artist_id   
album_name
rec_id
image_id

:Songs
id  -  auto-inc
album_id
genre_id
mp3_id
lyrics

:Genre
id  -  auto-inc
genre

:Recording
id  -  auto-inc
recording_studio
date

:Album Image
id  -  auto-inc
image

:Artist Info
id  -  auto-inc
info

:Mp3
id  -  auto-inc
mp3_location

Any other suggestions are welcome.

B.J.Rumsey



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




[PHP-DB] Simple Display

2002-02-08 Thread Barry Rumsey

I am trying to do a simple fetch of the lastest add name. I have the 
following code :
$query = SELECT name FROM name ORDER BY name DESC LIMIT 1;
$latename = mysql_query($query) or die(Select Failed!);
$latename = mysql_fetch_array($latename);
echo bLastest Name Added:/b  $latename

I know I am doing something wrong as being new to php it get be confused.
It returns : Lastest Name Added: Array

Could someone please point out where i'm going wrong

Thank you



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




[PHP-DB] option in forms

2002-02-08 Thread Barry Rumsey

I know how to do the option call e.g.
This is the list of artists already in our database :
SELECT name=artist
?php echo $option_block; ?
/SELECT
But I want to do a form where they select the option then fill out rest 
of form. The option above returns the artist name, but I want to insert 
the artistid.



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




[PHP-DB] Re: Count(*)

2002-01-24 Thread Barry Rumsey








  
  Thank you everyone. The "COUNT(*) AS c" worked great.
  
  ---Original Message---
  
  
  From: Kai Voigt
  Date: Friday, 25 
  January 2002 11:11:06 a.
  To: Barry Rumsey
  Cc: [EMAIL PROTECTED]
  Subject: Re: 
  Count(*)
  Barry Rumsey wrote: I have this small query on a 
  page:emit source="sql" host=xoops query= SELECT COUNT(*) FROM 
  xp_topics WHERE artist='artist' ORDER BY topicid DESC LIMIT 
  1"sql.artist;/emitUse "SELECT COUNT(*) AS C FROM 
  ..." instead. Then you can access thecount value as 
  sql.c;Kai-- dreiecksplatz 8, d-24105 kiel, 
  +49-431-22199869, http://k.123.org/.





	
	
	
	
	
	
	




 IncrediMail - Email has finally evolved - 
Click 
Here



Re: [PHP-DB] Books and what nots

2002-01-23 Thread Barry Rumsey








  Just got back from Newmarket. Yes they had 1 copy of the book and got 
  her to put it aside for me. Now it's down to some hard reading in my spare 
  time or even take it to work.
  Thanks
  
  ---Original Message---
  
  
  From: DL Neil
  Date: Thursday, 24 
  January 2002 9:25:06 a.
  To: Barry Rumsey
  Cc: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] 
  Books and what nots
  
  and as they say "if we haven't got it in stock, we'll get it in for 
  you..."
  
  At Newmarket one of the staff is reasonably 'up' on computer books - 
  the others tend to take deep breaths and roll their eyes. Just in case, 
  the ISBN is 0-672-31784-2 (but that may have changed if a new edition has 
  been published).
  
  Regards,
  =dn
  
  
- Original Message - 
From: 
    Barry Rumsey 
To: [EMAIL PROTECTED] 

Cc: [EMAIL PROTECTED] 
Sent: 23 January 2002 18:31
Subject: Re: [PHP-DB] Books and 
what nots


  
  

  No haven't tried Amazon because I haven't got a credit card, 
  used to ,but it got me into a lot of trouble. No I'll head down to 
  tech books in a couple of of hours when they open.
  
  ---Original 
  Message---
  
  
  From: DL Neil
  Date: Thursday, 
  24 January 2002 7:23:17 a.
  To: Barry Rumsey
  Cc: [EMAIL PROTECTED]
  Subject: Re: 
  [PHP-DB] Books and what nots
  
  Barry,
  You can't buy a decent computer book for less than 
  NZD100!
  That's a fair price against what I paid.
  The USD price looks even worse. 
  Tried Amazon etc?
  =dn
  
  snip 
  
  

  


  
  
  
  





	
	
	
	
	
	
	




 IncrediMail - Email has finally evolved - 
Click 
Here



RE: [PHP-DB] # of Records in Table

2002-01-23 Thread Barry Rumsey








  Zach wrote:
   "I do generally find that the more brief I am in 
  describing an issue, themore likely I am to get a reply. Then details 
  can be given if needed, infurther correspondences."
  
  I would like to disagree with this. I am only a newbie to php and 
  have found that if I can describe to my best ability the problem I'm 
  having I can get a reply that helps me in the best way in 1 or 2 replies. 
  There is none of this back and forward and end up still getting nowhere. 
  You have towait for some replies, but they are worth it.
  
  ---Original Message---
  
  
  From: Zach Curtis
  Date: Thursday, 24 
  January 2002 1:02:07 p.
  To: DL Neil
  Cc: [EMAIL PROTECTED]
  Subject: RE: [PHP-DB] # 
  of Records in Table
  There are many columns of data in the table. The only 
  column that I wouldlike to extract a value from is the password field 
  (this is the key aswell). I do not have an AUTO_INCREMENT field. 
  Although, I see how addingthat field could be of use by using it with 
  the SELECT MAX() as youmentioned.The last record is whatever 
  the last record was inserted using INSERT INTO.To give you the overall 
  picture of what I am trying to accomplish:1) I am opening up a db 
  table and searching for the password of the lastrecord in the 
  table2) I then open a flat file and search for that password and grab 
  the nextrecord after that (as records are appended to the end of the 
  flat file) andany other subsequent records added to the flat 
  file3) Write those new records to the db tableIn this 
  scenario, the last record would be the last record from the flatfile 
  added to the db table.Another suggestion from [EMAIL PROTECTED] 
  was to:Select your password field, and whatever other fields you 
  need toUse-mysql_num_rows() to capture the number of rows 
  returned-mysql_data_seek() to position pointer on last row (remember 
  indexingstarts at 0)-mysql_fetch_row() or mysql_fetch_array(), 
  your choice, to return thedata.This is done with one select 
  statement, however all the passwords from thetable have to be loaded 
  into array (perhaps not the most efficient way? Butbetter than what I 
  had come up with.).I do generally find that the more brief I am in 
  describing an issue, themore likely I am to get a reply. Then details 
  can be given if needed, infurther correspondences.I will give 
  that AUTO_INCREMENT and SELECT MAX() a try as 
  well.Zach-Original Message-From: DL Neil 
  [mailto:[EMAIL PROTECTED]]Sent: 
  Wednesday, January 23, 2002 3:27 PMTo: Zach CurtisCc: [EMAIL PROTECTED]Subject: 
  Re: [PHP-DB] # of Records in TableZach,We're going back 
  and forth on this and getting no where...So far all you have 
  informed us is that the table has one column, whichcontains a bunch of 
  passwords (I alsosuggest that this is not really the case and there'll 
  at least be some sortof userId field - but you haven'tbothered to 
  tell me/us that)The concept of "last" in relational terminology is 
  ambiguous. Do you meanlast entered, or do you mean the rowwith the 
  field containing the highest value in the column - for 
  example.Some people are used to the idea that there is also some 
  'phantom' rowIdthat counts/labels each row. In otherfile systems 
  this might have been the case, but the physically last recordin an 
  RDBMS table-file may notconform to either of the "last" definitions 
  mentioned above. There is nosuch 'highest' in an RDBMS unless 
  youput it there - as mentioned by another correspondent, it's a good 
  idea touse some sort of 'id' field in everytable. This can be 
  generated for you with the AUTO_INCREMENT feature. Withappropriate 
  design, eg first recordhas id=1 and the succeeding records have id-s 
  with ascending values, thenyou can use SELECT MAX() against 
  the'id' or possibly against the AUTO_INCREMENT feature.These 
  commands are well documented - RTFM. Many tutorials with plenty 
  ofexamples of authentication techniquesexist on the PHP/MySQL web 
  sites.Next time, please don't be so (repeatedly) parsimonious in 
  the provision ofinformation, if you expect/hope thatsomeone is 
  going to give their (free) time to help you out. 
  (grumble)=dn- Original Message -From: 
  "Zach Curtis" lt;[EMAIL PROTECTED]To: "DL 
  Neil" lt;[EMAIL PROTECTED]Cc: 
  lt;[EMAIL PROTECTED]Sent: 
  23 January 2002 21:52Subject: RE: [PHP-DB] # of Records in 
  Table The key field is the password field, which is also 
  the field that I would like to retrieve for that last 
  record. Zach -Original 
  Message- From: DL Neil [mailto:[EMAIL PROTECTED]] 
  Sent: Wednesday, January 23, 

[PHP-DB] Counter view total

2002-01-21 Thread Barry Rumsey








  In one of my tables I have a field called count_view, How do I add 
  all the totals up to come up with one grand total of 
  views.







 IncrediMail - Email has finally evolved - 
Click 
Here

[PHP-DB] distinct - how to do

2002-01-19 Thread Barry Rumsey

I have the following query:
$query = SELECT  * FROM xp_topics, xp_stories WHERE xp_topics.topicid = 
xp_stories.topicid AND xp_topics.artistname='Faith Hill' ORDER BY topictext DESC LIMIT 
0,20; 
It returns the lot but a lot of doubles.
 I want to put a DISTINCT call the query, but if I put it after the select ( select 
distinct * from...) it returns nothing. How do you do a DISTINCT?



[PHP-DB] very simple answer

2002-01-17 Thread Barry Rumsey

I can't figure out where I have gone wrong. Maybe not enough sleep, anyway this is the 
simple query:
$query = SELECT * FROM xp_topics WHERE artist='artist'ORDER BY topicid DESC LIMIT 
0,1; $result = mysql_db_query($query) or die(Select Failed!);
echo(Latest Artists : $topictext br);

It says query failed. I know I've forgoten something but don't know what



Re: [PHP-DB] very simple answer

2002-01-17 Thread Barry Rumsey

I ended up rewriting it again and somewhere I must have done something wrong
as it now works. Thanks guys. Maybe I should think about more sleep.

- Original Message -
From: Miles Thompson [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, January 18, 2002 9:48 AM
Subject: Re: [PHP-DB] very simple answer


 Barry,

 Add or die( mysql_errno() . : . mysql_error() )  

 It could be you don't have any data, also there's no space between
/artist'
 and ORDER BY.

 Also trim off everything after 'artist' and see what you get. If it still
 doesn't work there's something wrong with the field names. Then start
 adding stuff back. BTW you don't need ORDER BY if you are LIMITing to 1.
g

 Miles

 At 08:52 AM 1/18/2002 +1300, Barry Rumsey wrote:
 I can't figure out where I have gone wrong. Maybe not enough sleep,
anyway
 this is the simple query:
 $query = SELECT * FROM xp_topics WHERE artist='artist'ORDER BY topicid
 DESC LIMIT 0,1; $result = mysql_db_query($query) or die(Select
Failed!);
 echo(Latest Artists : $topictext br);
 
 It says query failed. I know I've forgoten something but don't know what





-- 
PHP Database 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-DB] Count

2002-01-16 Thread Barry Rumsey

How do you add a count feature to a link. I can get stuff from the db but want to know 
how many times it's been read or click on?



[PHP-DB] How are site layout blocks made

2002-01-12 Thread Barry Rumsey

I'll ask this question again but in a different way.
In these php news portals like phpnuke, myphpnuke, they lay their site out in these so 
called blocks.I'm looking for information on how these blocks are made, are they done 
in php or html and where can I find more information on this.



Re: [PHP-DB] PHP blocks

2002-01-11 Thread Barry Rumsey

ones like phpnuke, myphpnuke, postnuke etc

- Original Message - 
From: olinux [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]
Sent: Friday, January 11, 2002 7:26 PM
Subject: Re: [PHP-DB] PHP blocks


 What portals?
 
 olinux
 
 --- Barry Rumsey [EMAIL PROTECTED] wrote:
  
  On these web portals they have things call blocks
  that arrange the layout of the site. Where can one
  go to learn how to do this sort of layout.
  
 
 
 __
 Do You Yahoo!?
 Send FREE video emails in Yahoo! Mail!
 http://promo.yahoo.com/videomail/
 



-- 
PHP Database 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-DB] multiple tables insert

2002-01-11 Thread Barry Rumsey

 Thanks for that.
But it has brought up another question. I'll list the tables so you'll know
what i'm on about.
TABLE 1 : Album
alb_id int(11) NOT NULL auto_increment,
  art_id int(11) NOT NULL default '0',
  alb_name varchar(255) NOT NULL default '',
  alb_image varchar(255) NOT NULL default '',
  alb_year date NOT NULL default '-00-00',
  alb_genre varchar(100) NOT NULL default '',
  PRIMARY KEY  (alb_id)

TABLE 2 : Artist
art_id int(11) NOT NULL auto_increment,
  art_name varchar(255) NOT NULL default '',
  art_details mediumtext NOT NULL,
  PRIMARY KEY  (art_id)

TABLE 3 : Songs
song_id int(11) NOT NULL auto_increment,
  song_name varchar(255) NOT NULL default '',
  song_lyrics mediumtext NOT NULL,
  song_info mediumtext NOT NULL,
  PRIMARY KEY  (song_id)

TABLE 4 : Tracks
track_id int(11) NOT NULL auto_increment,
  alb_id int(11) NOT NULL default '0',
  art_id int(11) NOT NULL default '0',
  song_id int(11) NOT NULL default '0',
  PRIMARY KEY  (track_id)

Ok I'll be able to work out the simple part of the inserts, but what about
the auto_increment parts thatt relie on the information in the other files.
eg: 'artist.art_id' should be the same as 'album.art_id'  the problem is
that 'artist.art_id' is auto_increment and 'album.art_id'   is not. So if  I
added an artist in the artist table and the auto_increment gave it the value
of 5, how would I update the 'album.art_id'  with the same value?













- Original Message -
From: Miles Thompson [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Saturday, January 12, 2002 9:50 AM
Subject: Re: [PHP-DB] multiple tables insert


   Barry

 See below ...

 At 09:09 AM 1/12/2002 +1300, Barry Rumsey wrote:
 Two questions:
 1) If I have a url in the db that points to a image , how do I get php to
 get this image and display it ?

 Check the IMG tag in an HTML reference


 2) I have 4 tables in the db and would like to know of a good tutorial on
 inserting to multiple tables form a single form.

 There are many tutorials, the one I most frequently recommend is by Julie
 Meloni at http://www.thickbook.com  pick the one on custom error messages
 as she develops it very nicely.

 As for the inserts, in the processing part of the script, you'll know
 what I mean when you examine the tutorial, execute an INSERT for the data
 you want to insert in each of the tables. INSERT acts on one table at a
 time, so you'll have four of them.

 That should get you going - Miles Thompson



 --
 PHP Database 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 Database 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-DB] multiple tables insert

2002-01-11 Thread Barry Rumsey

I had been looking for a pre made script for a lyric site like phpnuke but
the only one I could find was myphplyrics which is quite hopeless ,so I've
had no choice but to try and make my own any way I would like to thank you
for all your help so far.

B.J.Rumsey.
- Original Message -
From: Miles Thompson [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Saturday, January 12, 2002 12:51 PM
Subject: Re: [PHP-DB] multiple tables insert


 Barry,

 Good question, and you have discovered one of MySQL's limitations, it does
 not enforce functional constraints. To put it another way, you can design
 parent-child relationships, but the db will never say You can't add this
 because the parent record doesn't exist. So you have to do it in code,
not
 a big deal,and it's been done that way for years with other flat file,
 pseudo-relational database -- FoxPro, dBase, etc.

 You work around it by capturing the auto_increment value using the
 mysql_insert_id() function. Hence you can insert the values for the artist
 table, call mysql_insert_id() and assign it to a variable, say
$art_id_key,
 and use it in the insert for the album  table. Then repeat, calling
 mysql_insert_id() and assigning it to $album_id_key after the insert into
 the album table so that you will have it for the insert into the tracks
 table. And so forth.

 You will be doing all these inserts on the same thread, so if someone else
 inserts into the same table you should be safe, according to the
 documentation. If A inserts into artist, B inserts into artist, then A
 calls mysql_insert_id() the value returned is for A's insert, not B's.
 MySQL has a separate thread for each of A and B.

 Now, don't trust me. Read up on the last_insert_id() and mysql_insert_id()
 functions in both the MySQL and PHP docs.

 I'll toss this out - what if you decide to capture other information, such
 as the name of the producer. Can your design handle that? What changes
 might you have to make to accommodate the change?

 Regards - Miles Thompson

 At 10:17 AM 1/12/2002 +1300, Barry Rumsey wrote:
   Thanks for that.
 But it has brought up another question. I'll list the tables so you'll
know
 what i'm on about.
 TABLE 1 : Album
 alb_id int(11) NOT NULL auto_increment,
art_id int(11) NOT NULL default '0',
alb_name varchar(255) NOT NULL default '',
alb_image varchar(255) NOT NULL default '',
alb_year date NOT NULL default '-00-00',
alb_genre varchar(100) NOT NULL default '',
PRIMARY KEY  (alb_id)
 
 TABLE 2 : Artist
 art_id int(11) NOT NULL auto_increment,
art_name varchar(255) NOT NULL default '',
art_details mediumtext NOT NULL,
PRIMARY KEY  (art_id)
 
 TABLE 3 : Songs
 song_id int(11) NOT NULL auto_increment,
song_name varchar(255) NOT NULL default '',
song_lyrics mediumtext NOT NULL,
song_info mediumtext NOT NULL,
PRIMARY KEY  (song_id)
 
 TABLE 4 : Tracks
 track_id int(11) NOT NULL auto_increment,
alb_id int(11) NOT NULL default '0',
art_id int(11) NOT NULL default '0',
song_id int(11) NOT NULL default '0',
PRIMARY KEY  (track_id)
 
 Ok I'll be able to work out the simple part of the inserts, but what
about
 the auto_increment parts thatt relie on the information in the other
files.
 eg: 'artist.art_id' should be the same as 'album.art_id'  the problem is
 that 'artist.art_id' is auto_increment and 'album.art_id'   is not. So if
I
 added an artist in the artist table and the auto_increment gave it the
value
 of 5, how would I update the 'album.art_id'  with the same value?
 
 
 
 
 
 
 
 
 
 
 
 
 
 - Original Message -
 From: Miles Thompson [EMAIL PROTECTED]
 To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Saturday, January 12, 2002 9:50 AM
 Subject: Re: [PHP-DB] multiple tables insert
 
 
 Barry
  
   See below ...
  
   At 09:09 AM 1/12/2002 +1300, Barry Rumsey wrote:
   Two questions:
   1) If I have a url in the db that points to a image , how do I get
php to
   get this image and display it ?
  
   Check the IMG tag in an HTML reference
  
  
   2) I have 4 tables in the db and would like to know of a good
tutorial on
   inserting to multiple tables form a single form.
  
   There are many tutorials, the one I most frequently recommend is by
Julie
   Meloni at http://www.thickbook.com  pick the one on custom error
messages
   as she develops it very nicely.
  
   As for the inserts, in the processing part of the script, you'll
know
   what I mean when you examine the tutorial, execute an INSERT for the
data
   you want to insert in each of the tables. INSERT acts on one table at
a
   time, so you'll have four of them.
  
   That should get you going - Miles Thompson
  
  
  
   --
   PHP Database 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 Database Mailing

[PHP-DB] simple question

2002-01-10 Thread Barry Rumsey


I have a colum with the numbers between 0-9 ( table is a list of bands  )eg. 2 live 
crew , 2pac , 1 maniacs also in this table Ihave normal names like : abba , queen 
, police etc..

How would I query the table to list only the ones starting with numbers.



[PHP-DB] count

2002-01-10 Thread Barry Rumsey

I'm trying to do the following query:

$db_connect = mysql_connect($sqlhostname,$login,$password);
$base_selection = mysql_select_db($base,$db_connect);
$query = SELECT DISTINCT * FROM xp_topics WHERE artist_count='artist' AND topictext 
LIKE 
  'A%' ORDER BY artist_count ASC limit 0,5; $req = mysql_query($query); 
  $res = mysql_num_rows($req); if ($res == 0)


 { echo /p
  pbN/A/b;} else { while($row = mysql_fetch_array($req))
$query2 = SELECT SUM(1) FROM xp_stories,xp_topics WHERE xp_topics.topicid = 
xp_stories_topicid AND xp_topics.topictext = '$topictest';
$numtopic = mysql_query($query2) or die(Select Failed!);
$numtopic = mysql_fetch_array($numtopic);
{ extract($row); echo ($topictext $numtopic[0]br
); } } 
   ?

Which should return a name and then count how many topics by that person.

If I leave out the query2 statement I do get a list of name, but I can't get query2 to 
work.



[PHP-DB] PHP blocks

2002-01-10 Thread Barry Rumsey


On these web portals they have things call blocks that arrange the layout of the site. 
Where can one go to learn how to do this sort of layout.



[PHP-DB] query and count

2002-01-09 Thread Barry Rumsey

I have two tables, the first one I query like :

$query = SELECT * FROM xp_topics WHERE artist_count='artist' AND topictext LIKE 
  'B%' ORDER BY artist_count DESC limit 0,5; $req = mysql_query($query); 
  $res = mysql_num_rows($req); if ($res == 0) { echo /p
  pbSorry there is no result./b;} else { while($row = 
mysql_fetch_array($req)) 
{ extract($row); echo ($topictextbr
); } } 

The second one I want to do a count for each one that was returned above. eg Billie 
(2) , Bill (4) Bret (1)
 How would I set up the query to do both?



[PHP-DB] count query

2002-01-08 Thread Barry Rumsey

Is it posible to do a count(*) on a tabe where id=2  and count just those that id  = 2



[PHP-DB] Formated Results

2002-01-07 Thread Barry Rumsey

Hi
I have a database that has lyrics in it. I can get them to list but they are not 
aligned the same as whats in the database. How can I get the results aligned as whats 
in the database ?



Re: [PHP-DB] Formated Results

2002-01-07 Thread Barry Rumsey

Yes thank you that was the answer.
While I'm asking questions , I've got one good one :
Whats the best book to buy on  php  mysql ?
- Original Message -
From: Andrey Hristov [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, January 08, 2002 1:27 AM
Subject: Re: [PHP-DB] Formated Results


 Try printing pre before and /pre after them


 Regards,
 Andrey Hristov
 - Original Message -
 From: Barry Rumsey [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, January 07, 2002 2:19 PM
 Subject: [PHP-DB] Formated Results


 Hi
 I have a database that has lyrics in it. I can get them to list but they
are not aligned the same as whats in the database. How can
 I get the results aligned as whats in the database ?





-- 
PHP Database 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-DB] ABC listings

2002-01-07 Thread Barry Rumsey

One last question for tonight as I have been given alot of help from this group to 
keep me going for awhile.

I would like to set up one of those  A B C D E F  page listings. How do i query the 
database to grab the first letter from each entrey.



[PHP-DB] Blocks

2002-01-07 Thread Barry Rumsey

Hi

In these web portals they have these things called blocks, is there a tutorial on how 
to do these anywhere



[PHP-DB] DESC LIMIT

2002-01-07 Thread Barry Rumsey

$query = SELECT * FROM xp_sings,xp_artist,xp_songs WHERE xp_artist.artist_id = 
xp_sings.artist_id AND xp_sings.song_id = xp_songs.song_id AND song_name LIKE 'b%'  
DESC LIMIT 5;
$req = mysql_query($query);
$res = mysql_num_rows($req);

if ($res == 0)
{ echo centerbSorry there is no result./b/center;}
else
{ while($row = mysql_fetch_array($req))
{
extract($row);

It returns as Sorry there is no result but if I leave of the DESC and limit , it 
works. Can someone tell me where I'm going wrong.






[PHP-DB] help on mulit query

2002-01-06 Thread Barry Rumsey

Hi
I have three tables set out below:

xp_artist: artist_id , artist _name
xp_sings: artist_id , songs_id
xp_songs: songs_id , song_name , lyrics

I can not figure out how to query and return the results for a  query like:

select song_name FROM xp_artist,xp_sings,xp_songs WHERE xp_artist.artist_id = 
xp_sings.artist_id AND xp_sings.song_id = xp_songs.songs_id AND artist_name LIKE 'b%';




Re: [PHP-DB] help on mulit query

2002-01-06 Thread Barry Rumsey

I did not see that ( I must be blind hehe ). One other question , I have the
lyrics also stored in the database, how can I create a link so that when the
query is returned they can click on song name and the lyrics will be viewed?
- Original Message -
From: Bogdan Stancescu [EMAIL PROTECTED]
To: Barry Rumsey [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, January 07, 2002 1:51 PM
Subject: Re: [PHP-DB] help on mulit query


 You seem to be doing it fine as far as I can see, except for song_id
which should be songs_id in the query...

 Bogdan

 Barry Rumsey wrote:

  Hi
  I have three tables set out below:
 
  xp_artist: artist_id , artist _name
  xp_sings: artist_id , songs_id
  xp_songs: songs_id , song_name , lyrics
 
  I can not figure out how to query and return the results for a  query
like:
 
  select song_name FROM xp_artist,xp_sings,xp_songs WHERE
xp_artist.artist_id = xp_sings.artist_id AND xp_sings.song_id =
xp_songs.songs_id AND artist_name LIKE 'b%';


 --
 PHP Database 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 Database 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]