Jump to content

Recommended Posts

I tried the code below

 

<?php require_once 'settings.php';

$query = "SELECT * FROM pbs WHERE ID = '1'";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
  $bestTimes[] = $row;

foreach($bestTimes as $distance => $time)
  if(!empty($time))
    echo $distance." = ".$time."<br>";
        
        ?>

 

but insted out getting the output

 

100m = 10.0

300m = 30.0

 

i just get array = 0

 

 

my table looks like this

 

100 200 300

10.0      30.0

 

im trying just to displays those entries that have a time in them

 

 

ID = 1

100m = 10:0

300m = 35:0

Array ( [iD] => 1 [100m] => 10:0 [200m] => [300m] => 35:0 )

 

 

maybe you can offer some advice how i can do this better....

 

i want users to be able to insert there personal bests..

so the output would look something like

 

  pb        time

 

100m      11.00

200m      33.00

800m        2.07.4

 

but they can have an list of pbs to chose from 100/200/300/400/800/1000/3000/5000 ect.. but only the ones they chose and fill in get shown on their profile..

 

i have 2 problems realy.. how to get them to fill there pbs in and edit them and also how to show it on their profile page

You could store the distance in one field. eg;

 

CREATE TABLE pbs (
  id INT NOT NULL AUTO_INCREMENT,
  uid INT,
  distance INT,
  pb INT
  PRIMARY KEY (id)
);

 

Then, say user 1 had done 100m in 11 seconds and 200m in 33secs.....

 

INSERT INTO pbs (uid, distance, pb) VALUES (100, 11);
INSERT INTO pbs (uid, distance, pb) VALUES (200, 33);

 

You would then use....

 

SELECT distance, pb FROM pbs WHERE uid = 1;

 

To get user 1's times.

-- --------------------------------------------------------

--
-- Table structure for table `pbs`
--

CREATE TABLE IF NOT EXISTS `pbs` (
  `ID` tinyint(99) NOT NULL auto_increment,
  `100m` varchar(4) NOT NULL default '',
  `200m` varchar(4) NOT NULL default '',
  `300m` varchar(4) NOT NULL default '',
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `pbs`
--

INSERT INTO `pbs` (`ID`, `100m`, `200m`, `300m`) VALUES
(1, '10:0', '', '35:0');

ok im going with that :D

 

what would you say is the best way of collecting th users id's and pb's ... this one has had me stumped.. 

 

textbox or drop down menus...

how would i select how many to show?

how would i show them so they can be edited?

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.