Jump to content

Drawing from and Sending to a Database


noirsith

Recommended Posts

I looked through one of the tutorials listed here on connecting to database and was able to implement it, however my novice level in php still gives me trouble with what I'm trying to do so let me try to explain what I need to do and see how hard it would be to implement and if you guys have any recommendations.

 

I'm trying to construct a quiz.

 

I would like the question to be loaded from one table in the database (say called questions). The answers would be multiple choice and I would like the selected answers to be stored in another table called answers that will be tallied according to the Primary ID say the last name field.

 

 

So essentially I need my main php or php files to call the database for questions and send data to the database when it comes to answers. What would be the code to do that? I'm even willing to settle with the questions being in main php file (as in not being called but being static) but answers would have to be sent and stored in my back-end database.

 

Any help would be greatly appreciated. Thank you!

Link to comment
https://forums.phpfreaks.com/topic/116409-drawing-from-and-sending-to-a-database/
Share on other sites

I don't know how to go about showing it to you ...

 

but essentially my database is going to be named noirsith_basicgrammar

 

tables within it will be: tblQuestions (with just autoID also the primary key to number them and the actual row of questions) and tblAnswers (with rows for fName, lName, ID, ans1, ans2, ans3 and so on)

 

I've set it up currently at blackapplehost.com if you want the login to take a peek lemme know.

 

Here's what I have,

 

Table 1

 

-- phpMyAdmin SQL Dump

-- version 2.8.2

-- http://www.phpmyadmin.net

--

-- Host: localhost

-- Generation Time: Jul 24, 2008 at 02:35 PM

-- Server version: 5.0.27

-- PHP Version: 4.3.10-16

--

-- Database: `noirsith_basicgrammar`

--

 

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

 

--

-- Table structure for table `tblQuestions`

--

 

CREATE TABLE `tblQuestions` (

  `Number` varchar(2) NOT NULL,

  `Questions` varchar(255) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

--

-- Dumping data for table `tblQuestions`

--

 

Table 2

 

--

-- Table structure for table `tblAnswers`

--

 

CREATE TABLE `tblAnswers` (

  `ID` int(6) NOT NULL,

  `fName` varchar(255) NOT NULL,

  `lName` varchar(255) NOT NULL,

  `Ans1` varchar(255) NOT NULL,

  `Ans2` varchar(255) NOT NULL,

  `Ans3` varchar(255) NOT NULL,

  `Ans4` varchar(255) NOT NULL,

  `Ans5` varchar(255) NOT NULL,

  `Ans6` varchar(255) NOT NULL,

  `Ans7` varchar(255) NOT NULL,

  `Ans8` varchar(255) NOT NULL,

  `Ans9` varchar(255) NOT NULL,

  `Ans10` varchar(255) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

--

-- Dumping data for table `tblAnswers`

--

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.