[GLLUG] Retrieving a row from mysql
sbdataspiller at sbcglobal.net
Tue Feb 17 10:58:48 EST 2004
(Sorry if people receive this again. Got a message saying my email was
too long so I shortened it)
I did the echo suggestion:
$query= "SELECT * FROM <tablename> WHERE accnum= $accnum"; echo 'query';
The out put was:
SELECT * FROM <tablename> WHERE accnum= 1.
Will that space in front of the 1 confuse the query? When I saw that, I
changed every thing to char's instead of int.
I'm close, real close to getting this thing working. Thanks to every
ones help and suggestions.
Also, that table that I used in my last email was just an example.
Here is one real query:
$player_query = mysql_query("SELECT player_name AS player_name,
total_games AS total_games,
squad_id AS squad_id
WHERE id='$id' AND accnum='$accnum'
LIMIT 1") or die(mysql_error());
All I did to the above query was to add the AND accnum='$accnum' to the
WHERE clause. That is all I have done through out the whole
Application, and modified the table structures (see below). Before I
added all the stuff for accnum, this worked perfectly.
There are 9 tables total, this is just one of them. All I did to the
others was to add the accnum field.
STATS TABLE (taken from a php script):
$query = mysql_query("CREATE TABLE $stats_table ( id smallint(5)
unsigned NOT NULL auto_increment,
player_name varchar(16) NOT NULL default '',
last_played datetime NOT NULL default '0000-00-00 00:00:00',
squad_id int(11) NOT NULL default '0',
accnum char(10) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
);") or die(mysql_error());
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the linux-user