Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
phpmyadmin index key issues/question
Old 03-05-2009, 12:21 PM phpmyadmin index key issues/question
Average Talker

Posts: 15
Trades: 0
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..
lukie_boy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-05-2009, 12:35 PM Re: phpmyadmin index key issues/question
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
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.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 03-05-2009, 12:48 PM Re: phpmyadmin index key issues/question
Average Talker

Posts: 15
Trades: 0
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); 
lukie_boy is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 02:01 PM Re: phpmyadmin index key issues/question
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
WHERE 2
==>
WHERE `index`='q2'
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 02:53 PM Re: phpmyadmin index key issues/question
Average Talker

Posts: 15
Trades: 0
nah still doesn't work would this help ?

PHP Code:
-- phpMyAdmin SQL Dump
-- version 3.1.1
-- http://www.phpmyadmin.net
--
-- 
Hostlocalhost
-- Generation TimeMar 052009 at 07:51 PM
-- Server version5.1.30
-- PHP Version5.2.8

SET SQL_MODE
="NO_AUTO_VALUE_ON_ZERO";

--
-- 
Database: `level1`
--

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

--
-- 
Table structure for table `correct`
--

CREATE TABLE IF NOT EXISTS `correct` (
  `
indexset('1','2','3','4','5','6'NOT NULL DEFAULT '1',
  `
level1text NOT NULL,
  `
level2text NOT NULL,
  `
level3text NOT NULL,
  `
level4text NOT NULL,
  `
level5text NOT NULL,
  `
level6text NOT NULL,
  `
level7text NOT NULL,
  `
level8text NOT NULL,
  `
level9text NOT NULL,
  `
level10text 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'''''''''''''''''''); 
lukie_boy is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 04:13 PM Re: phpmyadmin index key issues/question
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
You're inserting the same index over and over again...?
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 04:23 PM Re: phpmyadmin index key issues/question
Average Talker

Posts: 15
Trades: 0
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.
lukie_boy is offline
Reply With Quote
View Public Profile
 
Old 03-06-2009, 02:29 PM Re: phpmyadmin index key issues/question SOLVED
Average Talker

Posts: 15
Trades: 0
Okay now fixed I recreated the key...

PHP Code:
--
-- 
Table structure for table `correct`
--

CREATE TABLE IF NOT EXISTS `correct` (
  `
answerenum('1','2','3','4','5','6'NOT NULL,
  `
level1text NOT NULL,
  `
level2text NOT NULL,
  `
level3text NOT NULL,
  `
level4text NOT NULL,
  `
level5text NOT NULL,
  `
level6text NOT NULL,
  `
level7text NOT NULL,
  `
level8text NOT NULL,
  `
level9text NOT NULL,
  `
level10text 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.
lukie_boy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to phpmyadmin index key issues/question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.85068 seconds with 12 queries