phpmyadmin index key issues/question
03-05-2009, 12:21 PM
|
phpmyadmin index key issues/question
|
Posts: 15
|
Hi chaps I am putting together a table with 10 questions and I am trying to make it so it has 6 rows only, for each possible answer. I have been fiddling about with this and have got stuck. I can connect to the db/table no problem but when I put in WHERE 1 etc I just inserts it into every row.
I think my index key is setup wrong?
Dont suppose anyone could shed some light on this for me please.
Last edited by lukie_boy; 03-05-2009 at 12:38 PM..
|
|
|
|
03-05-2009, 12:35 PM
|
Re: phpmyadmin index key issues/question
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
We probably could, but you'll have to give us more information than that.
I didn't really understand what you meant about the table, 6 rows with answers etc., care to explain again? Perhaps show the table structure?
And could you show the code/queries your using.
|
|
|
|
03-05-2009, 12:48 PM
|
Re: phpmyadmin index key issues/question
|
Posts: 15
|
Okay sure , sorry if I didn't make myself clear
this is basicly whay I'm trying to do
index | 1 | 2 | 3 | 4 | 5 | 6 |
q1 |ans1|ans2|ans3|ans4|ans5|ans6|
q2 |ans1|ans2|ans3|ans4|ans5|ans6|
Well you get the idea trying to update column q1 row 1 but it is adding it to each row.
parsed from a form
PHP Code:
if ($quesnumber == "q1") {$querycorrect = "UPDATE correct SET q1='$correct1' WHERE 2";} else die("cannot update"); $info = mysql_query($querycorrect);
|
|
|
|
03-05-2009, 02:01 PM
|
Re: phpmyadmin index key issues/question
|
Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
|
WHERE 2
==>
WHERE `index`='q2'
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
|
|
|
|
03-05-2009, 02:53 PM
|
Re: phpmyadmin index key issues/question
|
Posts: 15
|
nah still doesn't work would this help ?
PHP Code:
-- phpMyAdmin SQL Dump -- version 3.1.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Mar 05, 2009 at 07:51 PM -- Server version: 5.1.30 -- PHP Version: 5.2.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- -- Database: `level1` --
-- --------------------------------------------------------
-- -- Table structure for table `correct` --
CREATE TABLE IF NOT EXISTS `correct` ( `index` set('1','2','3','4','5','6') NOT NULL DEFAULT '1', `level1` text NOT NULL, `level2` text NOT NULL, `level3` text NOT NULL, `level4` text NOT NULL, `level5` text NOT NULL, `level6` text NOT NULL, `level7` text NOT NULL, `level8` text NOT NULL, `level9` text NOT NULL, `level10` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC COMMENT='is correct/incorrect and value';
-- -- Dumping data for table `correct` --
INSERT INTO `correct` (`index`, `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `level7`, `level8`, `level9`, `level10`) VALUES ('1', 'correct', '', '', '', '', '', '', '', '', ''), ('1', 'correct', '', '', '', '', '', '', '', '', ''), ('1', 'correct', '', '', '', '', '', '', '', '', ''), ('1', 'correct', '', '', '', '', '', '', '', '', ''), ('1', 'correct', '', '', '', '', '', '', '', '', ''), ('1', 'correct', '', '', '', '', '', '', '', '', '');
|
|
|
|
03-05-2009, 04:13 PM
|
Re: phpmyadmin index key issues/question
|
Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
|
You're inserting the same index over and over again...?
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
|
|
|
|
03-05-2009, 04:23 PM
|
Re: phpmyadmin index key issues/question
|
Posts: 15
|
Sorry for any confusion here mate, I am trying to set up the index so that it has 6 rows to use to reference the answers hence index` set('1','2','3','4','5','6')
As I'm trying to set up this as a blank
template for a buddy of mine, so I figured auto increment would be the wrong way of
doing.
So he selects what is going into question1 answer6 with a form
and it will insert the data into row 6 of question1 only.
That pretty much what i'm trying to do, very badly it would seem, thanks for your patients so far.
If you can think of a better way to do this please suggest it.
|
|
|
|
03-06-2009, 02:29 PM
|
Re: phpmyadmin index key issues/question SOLVED
|
Posts: 15
|
Okay now fixed I recreated the key...
PHP Code:
-- -- Table structure for table `correct` --
CREATE TABLE IF NOT EXISTS `correct` ( `answer` enum('1','2','3','4','5','6') NOT NULL, `level1` text NOT NULL, `level2` text NOT NULL, `level3` text NOT NULL, `level4` text NOT NULL, `level5` text NOT NULL, `level6` text NOT NULL, `level7` text NOT NULL, `level8` text NOT NULL, `level9` text NOT NULL, `level10` text NOT NULL, KEY `answer` (`answer`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC COMMENT='is correct/incorrect and value';
-- -- Dumping data for table `correct` --
INSERT INTO `correct` (`answer`, `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `level7`, `level8`, `level9`, `level10`) VALUES ('1', 'incorrect', '', '', '', '', '', '', '', '', ''), ('2', 'other', '', '', '', '', '', '', '', '', ''), ('3', 'correct', '', '', '', '', '', '', '', '', ''), ('4', 'correct', '', '', '', '', '', '', '', '', ''), ('5', 'correct', '', '', '', '', '', '', '', '', ''), ('6', 'correct', '', '', '', '', '', '', '', '', '');
And the PHP command in am using to get this to work is...
PHP Code:
if ($quesnumber == "q1") {$querycorrect = "UPDATE correct SET level1='$correct1' WHERE answer='2'";} else die("cannot update");
Thanks everyone who helped me out here. 
|
|
|
|
|
« Reply to phpmyadmin index key issues/question
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|