Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Website Design/Showcase (http://www.chiefdelphi.com/forums/forumdisplay.php?f=64)
-   -   PHP, MySQL, and Dropdown lists (http://www.chiefdelphi.com/forums/showthread.php?t=29275)

evulish 29-06-2004 14:57

Re: PHP, MySQL, and Dropdown lists
 
Shouldn't you be doing something like UPDATE belt_owner SET $belt = '$new' WHERE wrestlername = 'Trent Sinn'. Or are these same people always going to have a belt? Could you maybe return the results of describe table; for the tables you're talking about? I'm not totally positive how you're doing this. I think I kinda see.. but it's a weird db design that I can't really grasp without seeing..

Raven_Writer 29-06-2004 15:04

Re: PHP, MySQL, and Dropdown lists
 
Quote:

Originally Posted by evulish
Shouldn't you be doing something like UPDATE belt_owner SET $belt = '$new' WHERE wrestlername = 'Trent Sinn'. Or are these same people always going to have a belt? Could you maybe return the results of describe table; for the tables you're talking about? I'm not totally positive how you're doing this. I think I kinda see.. but it's a weird db design that I can't really grasp without seeing..

My database is set up like this:

Table - Fields
---------------
admin - username, password
belt_owner -[list of belts]
news - [news stuff]
wrestler - [wrestler info]
------------------

The belt's values are who owns them. The reason for this is because a wrestler could hold more than 1 belt. I'm gonna keep it like this though (atleast for now).

I get what you're saying though. But my field is set up to enter the belt to change, the current holder, and the new holder. So, I can't really do it the way you did by specifically (sp?) saying who holds the belt.

Thanks though :)

evulish 29-06-2004 17:03

Re: PHP, MySQL, and Dropdown lists
 
Hrm. Okay.. so your belt_owner table has two columns.. one for the belt name and one for the owner of the belt? UPDATE belt_owner SET $belt = '$new' WHERE $belt = '$old' should be
Code:

UPDATE belt_owner SET wrestler_name = '$new' WHERE belt_name = '$belt'
I think..

(and what I meant by describe table.. was actually running 'describe table' in mysql.. so you get stuff like this:)
Code:

mysql> describe myposts;
+-------+--------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| title | varchar(60)  |      |    |        |                |
| date  | varchar(16)  |      |    |        |                |
| post  | mediumblob  |      |    |        |                |
| id    | mediumint(9) |      | PRI | NULL    | auto_increment |
+-------+--------------+------+-----+---------+----------------+
4 rows in set (0.09 sec)

or if the data isn't big in the table, do something like SELECT * FROM table LIMIT 3; so we can get an idea of what data you have in the table and it'll show the layout and stuff. Much easier than trying to describe you table to us :)

Raven_Writer 29-06-2004 17:30

Re: PHP, MySQL, and Dropdown lists
 
Quote:

Originally Posted by evulish
Hrm. Okay.. so your belt_owner table has two columns.. one for the belt name and one for the owner of the belt? UPDATE belt_owner SET $belt = '$new' WHERE $belt = '$old' should be
Code:

UPDATE belt_owner SET wrestler_name = '$new' WHERE belt_name = '$belt'

Nope, 1 column, the belt title (TV, Tag Team, etc...). The value for the column is the owner of the belt.

Quote:

(and what I meant by describe table.. was actually running 'describe table' in mysql.. so you get stuff like this:)

...

or if the data isn't big in the table, do something like SELECT * FROM table LIMIT 3; so we can get an idea of what data you have in the table and it'll show the layout and stuff. Much easier than trying to describe you table to us :)
Here's what I get:
+--------+------+---------+-------+--------+---------+----------+
|heavyweight|tv|cruiserweight|no_limits|tag_team1| tag_team2|team_name
+--------+------+---------+-------+--------+---------+----------+
|Devon Matthews|Trent Sinn|Red Ninja| | | |CIA|
+--------+------+---------+-------+--------+---------+----------+

The blank spots are vacant holdings.

If I wanted to change Trent Sinn to say, raevin, the code wouldn't work (aka: the Cruiserweight title will still say Trent Sinn).

evulish 29-06-2004 17:57

Re: PHP, MySQL, and Dropdown lists
 
Huh.. okay.. that's an interesting way to do it. Well, then your SQL line should have been right. Try printing it out to make sure the values are what you expect them to be.

Raven_Writer 30-06-2004 20:28

Re: PHP, MySQL, and Dropdown lists
 
Ok, 1 last question I think.

I got my other problems fixed so far, but now I'm having trouble showing the bio of the wrestler.

I can get it to show everything but the weight. I've been working on this for about 1.5 days, and I can't understand why it's not working:

PHP Code:

$query mysql_query("SELECT * FROM wrestler WHERE name = '$w_name'");
   
 while(
$row mysql_fetch_array($query)){
    
$rfinishers $row["finisher"];
    
$rtrademarks $row["trademark_move"];
    
$rtheme_song $row["theme_song"];
    
$rheight $row["height"];
    
$rweight $row["weight"];
    
$rfaction $row["faction"];
 } 

I've checked, and rechecked the column in the table, and it's not any different that what I have above.

If anyone can help me w/ this, I will gladly appreciate it.

evulish 30-06-2004 23:02

Re: PHP, MySQL, and Dropdown lists
 
Just for kicks, try print_r($row); which will print the array. Make sure it's set and you have the column name correct. The code is fine, so I'd guess it's something small.

Raven_Writer 01-07-2004 08:05

Re: PHP, MySQL, and Dropdown lists
 
Quote:

Originally Posted by evulish
Just for kicks, try print_r($row); which will print the array. Make sure it's set and you have the column name correct. The code is fine, so I'd guess it's something small.

I tried it, and the field is empty. Everything else is filled out, but that field is empty.


All times are GMT -5. The time now is 00:29.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi