-
Posts
442 -
Joined
-
Last visited
Everything posted by I-AM-OBODO
-
This is what i have done so far, but two problems; 1, the last number is duplicated 2, how can i make the numbers come in pair of three (12, 16, 18) thank you form <form id="form1" name="form1" method="post" action="show.php"> <table width="100%" border="0" cellspacing="2" cellpadding="1"> <tr> <td width="21%">Input Numbers : </td> <td width="79%"><input name="one" type="text" id="one" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="two" type="text" id="two" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="three" type="text" id="three" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="four" type="text" id="four" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="five" type="text" id="five" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="six" type="text" id="six" size="10" /></td> </tr> <tr> <td> </td> <td><input name="seven" type="text" id="seven" size="10" /></td> </tr> <tr> <td> </td> <td><input name="eight" type="text" id="eight" size="10" /></td> </tr> <tr> <td> </td> <td><input name="nine" type="text" id="nine" size="10" /></td> </tr> <tr> <td> </td> <td><input name="ten" type="text" id="ten" size="10" /></td> </tr> <tr> <td> </td> <td><input name="generate" type="submit" id="generate" value="Generate" /></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> show.php <?php $one = $_POST['one']; $two = $_POST['two']; $three = $_POST['three']; $four = $_POST['four']; $five = $_POST['five']; $six = $_POST['six']; $seven = $_POST['seven']; $eight = $_POST['eight']; $nine = $_POST['nine']; $ten = $_POST['ten']; $bingo = array($one,$two,$three,$four,$five,$six,$seven,$eight,$nine,$ten); shuffle($bingo); foreach ($bingo as $number) { echo "$number "; } echo $number; ?>
-
Thank you. but why i am using my own number instead of generating numbers with mt_rand() is because, i want the user to be able to input their own series of numbers so that the program shuffles and bring them in pairs.
-
Hi all, sorry cos there is no code. please how can i generate pairs (in twos, threes, fours or five) from a given set of numbers. the numbers are to be typed in the form text field and when click generate(submit button) it brings out the pair of numbers. thanks in advance my form <form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="1"> <tr> <td width="21%">Input Numbers : </td> <td width="79%"><input name="numbers" type="text" id="numbers" size="50" /></td> </tr> <tr> <td> </td> <td><input name="generate" type="submit" id="generate" value="Generate" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
-
create a form within a form by button trigger
I-AM-OBODO replied to I-AM-OBODO's topic in PHP Coding Help
but i have seen something of that sort. i am trying to model from what i saw in bamboo invoice an application built with codeigniter. whatever he used, i dont know but all i know is that when you click add button, it brings out another form field -
Hi, how can i create a form within a form with the click of a button? so that when i click add new item, it brings form fields under the current one. hope my explanation helps thanks <form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="22%">Invoice Number </td> <td width="78%"> </td> </tr> <tr> <td>Date Issued </td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="10%">Quantity</td> <td width="70%">Description</td> <td width="9%">Taxable</td> <td width="11%">Amnount</td> </tr> <tr> <td valign="top"><input name="textfield" type="text" size="7" /></td> <td valign="top"><textarea name="textfield2" cols="80"></textarea></td> <td valign="top"><input type="checkbox" name="checkbox" value="checkbox" /></td> <td valign="top"><input name="textfield3" type="text" size="12" /></td> </tr> <tr> <td colspan="4"><input type="submit" name="Submit" value="Add New Item" /></td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
-
1) You've got a mis-placed double-quote in there 2) You're missing a concatenation operator 3) Having the same "value" for all of them will not be very helpful echo "<option value ='" . $row['id'] . "'>" . $row['name'] . "</option>"; thanks. gat it now
-
Hi all, i want my list/menu field values to come from my database. how can i accomplish that? thanks i did <select name="select"> <option value="0">--select below--</option> <option value="1">Me</option> <?php require_once '../konnect/konex.php'; $result = mysql_query("SELECT * FROM is_clients"); while($row = mysql_fetch_array($result)) { echo "<option value ='2'>".$row"['name']</option>"; echo "<br />"; } ?> </select>
-
Hi all, pls, how can i change the error message color to red? thanks <?php echo form_open('form'); ?> <h5>First Name:</h5> <?php echo form_error('fname'); ?> <input type="text" name="fname" value="<?php echo set_value('fname'); ?>" size="50" /> <h5>Surname:</h5> <?php echo form_error('sname'); ?> <input type="text" name="sname" value="<?php echo set_value('sname'); ?>" size="50" /> <h5>Email Address</h5> <?php echo form_error('email'); ?> <input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" /> <h5>Password</h5> <?php echo form_error('password'); ?> <input type="password" name="password" value="<?php echo set_value('password'); ?>" size="50" /> <h5>Password Confirm</h5> <?php echo form_error('passconf'); ?> <input type="password" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" /> <div><input type="submit" value="Submit" /></div> </form>
-
Hi all, i keep getting double entry in my db. how do i stop it? guess my method is wrong. part of my code below thanks $form_data = array( 'id' => set_value(''), 'fname' => set_value('fname'), 'sname' => set_value('sname'), 'email' => set_value('email'), 'password' => set_value('password') ); $query = $this->db->query('SELECT email FROM reg_users'); if ($query >1) { echo 'Username Already exist'; } else{ if ($this->reg_model->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db { redirect('forms/success'); // or whatever logic needs to occur } thanks again
-
Hi i have tried various method to get the value of current date (which is a hidden field), but in my database it just 0000000 i get. the date dont seem to be inserted. i tried declaring date as a variable in my controller file ($date = date('Y-m-d H:i:s', now()) then passed it on to the db but no avail, i also tried declaring it on the view file still no avail. Where am i going wrong? thanks in advance My code View <?php // Change the css classes to suit your needs //$attributes = array('class' => '', 'id' => ''); echo form_open('services'); ?> <p> <label for="title">Title <span class="required">*</span></label> <?php echo form_error('title'); ?> <?php // Change the values in this array to populate your dropdown as required ?> <?php $options = array( '' => 'Please Select', 'mr' => 'Mr', 'mrs' => 'Mrs', 'miss' => 'Miss', 'ms' => 'Ms', 'dr' => 'Dr', 'prof' => 'Prof', 'alhaji' => 'Alhaji' ); ?> <br /><?php echo form_dropdown('title', $options, set_value('title'))?> </p> <p> <label for="surname">Surname <span class="required">*</span></label> <?php echo form_error('surname'); ?> <br /><input id="surname" type="text" name="surname" maxlength="25" value="<?php echo set_value('surname'); ?>" /> </p> <p> <label for="firstname">Firstname <span class="required">*</span></label> <?php echo form_error('firstname'); ?> <br /><input id="firstname" type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" /> </p> <p> <label for="email">Email <span class="required">*</span></label> <?php echo form_error('email'); ?> <br /><input id="email" type="text" name="email" maxlength="25" value="<?php echo set_value('email'); ?>" /> </p> <p> <label for="state">State <span class="required">*</span></label> <?php echo form_error('state'); ?> <br /><input id="state" type="text" name="state" maxlength="25" value="<?php echo set_value('state'); ?>" /> </p> <p> <label for="tel">Tel <span class="required">*</span></label> <?php echo form_error('tel'); ?> <br /><input id="tel" type="text" name="tel" maxlength="20" value="<?php echo set_value('tel'); ?>" /> </p> <p> <label for="topic">Topic <span class="required">*</span></label> <?php echo form_error('topic'); ?> <?php // Change the values in this array to populate your dropdown as required ?> <?php $options = array( '' => 'Please Select', 'paye' => 'PAYE', 'capital' => 'Capital Reconstruction', 'cash' => 'Cash Flow Forcasting', ); ?> <br /><?php echo form_dropdown('topic', $options, set_value('topic'))?> </p> <p> <label for="msg">Message <span class="required">*</span></label> <?php echo form_error('msg'); ?> <br /> <?php echo form_textarea( array( 'name' => 'msg', 'rows' => '5', 'cols' => '50', 'value' => set_value('msg') ) )?> </p> <p> <?php $date = date('Y-m-d H:i:s', now()); echo form_hidden( 'date', '$date'); ?> </p> <p> <?php echo form_submit( 'submit', 'Submit'); ?> </p> <?php echo form_close(); ?> controller <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Services extends CI_Controller { public function __construct() { parent::__construct(); //$this->load->library('form_validation'); //$this->load->database(); //$this->load->helper('form'); //$this->load->helper('url'); $this->load->model('services_model'); } public function view($page = 'easylife') { if ( ! file_exists('application/views/services/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('services/'.$page, $data); $this->load->view('templates/footer', $data); } public function index() { $this->form_validation->set_rules('title', 'title', 'required|trim|xss_clean|max_length[10]'); $this->form_validation->set_rules('surname', 'surname', 'required|trim|xss_clean|max_length[25]'); $this->form_validation->set_rules('firstname', 'firstname', 'required|trim|xss_clean'); $this->form_validation->set_rules('email', 'email', 'required|trim|xss_clean|valid_email|max_length[25]'); $this->form_validation->set_rules('state', 'state', 'required|trim|xss_clean|max_length[25]'); $this->form_validation->set_rules('tel', 'tel', 'required|trim|xss_clean|is_numeric|max_length[20]'); $this->form_validation->set_rules('topic', 'topic', 'required|trim|xss_clean|max_length[25]'); $this->form_validation->set_rules('msg', 'msg', 'required|trim|xss_clean|max_length[50]'); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == FALSE) // validation hasn't been passed { //$this->load->view('advisory'); $this->load->view('templates/header'); $this->load->view('services/advisory'); $this->load->view('templates/footer'); } else // passed validation proceed to post success logic { // build array for the model $form_data = array( 'title' => set_value('title'), 'surname' => set_value('surname'), 'firstname' => set_value('firstname'), 'email' => set_value('email'), 'state' => set_value('state'), 'tel' => set_value('tel'), 'topic' => set_value('topic'), 'msg' => set_value('msg'), 'date' => set_value('date') ); // run insert model to write data to db if ($this->services_model->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db { redirect('services/success'); // or whatever logic needs to occur } else { echo 'An error occurred saving your information. Please try again later'; // Or whatever error handling is necessary } } } function success() { echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note sessions have not been used and would need to be added in to suit your app'; } } ?>
-
Hi, i don't really know why my form isn't working, even when i click on empty, its still not validating. Here's my code: Controller <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Services extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('services_model'); } public function view($page = 'easylife') { if ( ! file_exists('application/views/services/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('services/'.$page, $data); $this->load->view('templates/footer', $data); } public function advisory() { $this->load->helper('form'); $this->load->library('form_validation'); //$data['title'] = 'Create a news item'; $this->form_validation->set_rules('title', 'Title', 'required'); $this->form_validation->set_rules('sname', 'Surname', 'required'); $this->form_validation->set_rules('fname', 'First Name', 'required'); $this->form_validation->set_rules('email', 'Email', 'required'); $this->form_validation->set_rules('state', 'State', 'required'); $this->form_validation->set_rules('tel', 'telephone', 'required'); $this->form_validation->set_rules('msg', 'Message', 'required'); if ($this->form_validation->run() === FALSE) { $this->load->view('templates/header', $data); $this->load->view('services/'.$page, $data); $this->load->view('templates/footer', $data); } else { $this->news_model->set_news(); $this->load->view('services/success'); } } } Model <?php class Services_model extends CI_Model { public function __construct() { $this->load->database(); } function insert_entry() { $data = array( 'title' => $title, 'sname' => $name, 'fname' => $name, 'email' => $name, 'state' => $name, 'tel' => $name, 'msg' => $name, 'date' => $date ); $this->db->insert('advisory', $data); } } View <?php echo validation_errors(); ?> <?php echo form_open('services/advisory'); ?> <table width="80%" border="0" cellspacing="2" cellpadding="0"> <tr> <td align="right"> Title:</td> <td><select name="title" id="title"> <option value="mr">Mr</option> <option value="mrs">Mrs</option> <option value="ms">Ms</option> </select></td> </tr> <tr> <td align="right">Surname:</td> <td><input name="sname" type="text" id="sname" /></td> </tr> <tr> <td align="right">First Name:</td> <td><input name="fname" type="text" id="fname" /></td> </tr> <tr> <td align="right">Email:</td> <td><input name="email" type="text" id="email" /></td> </tr> <tr> <td align="right">State:</td> <td><input name="state" type="text" id="state" /></td> </tr> <tr> <td align="right">Telephone</td> <td><input name="tel" type="text" id="tel" /></td> </tr> <tr> <td align="right">Topic:</td> <td><select name="topic" id="topic"> <option value="0" selected="selected">Select Topic</option> <option value="1">PAYE</option> <option value="2">Capital Restructuring</option> </select></td> </tr> <tr> <td rowspan="2"> </td> <td><textarea name="msg" id="msg"></textarea></td> </tr> <tr> <td><input name="date" type="hidden" id="date" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> thanks
-
are you saying i can have one controller but different models for each table?
-
Hi, I have different tables in my database. Do i need to create different models and controllers for each table or can i use one model and controllers for all the tables?
-
hi. after some gogling i finally figured it out. thanks all
-
my folder structure: application, css, images, js, system (index.php) on my view i have a file service.php and i attached a style <link href="../../css/styles.css" rel="stylesheet" type="text/css"> on my editor, i could see the effects of my styles but when i view in browser, no effects thanks
-
Hi, can i do an include in codeigniter? eg <?php include ‘menu.php’ ?> if possible, how can i achieve it. thanks
-
Hi, I created a css folder for all my styles, when i link the style on my editor i can see the style output but on the browser the style does not reflect. why is it so? what can i do to make it reflect. thank you
-
I had the same trouble with the tutorial and got stuck on the same new just like you. Although you have decided to move on but just in case you haven't gotten a solution pass the tutorials this is how mine was resolved. Model: the news_model.php file <?php class News_model extends CI_Model { public function __construct() { $this->load->database(); } public function get_news($slug = FALSE) { if ($slug === FALSE) { $query = $this->db->get('news'); return $query->result_array(); } $query = $this->db->get_where('news', array('slug' => $slug)); return $query->row_array(); } public function set_news() { $this->load->helper('url'); $slug = url_title($this->input->post('title'), 'dash', TRUE); $data = array( 'title' => $this->input->post('title'), 'slug' => $slug, 'text' => $this->input->post('text') ); return $this->db->insert('news', $data); } } Controller: news.php <?php class News extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('news_model'); } public function index() { $data['news'] = $this->news_model->get_news(); $data['title'] = 'News archive'; $this->load->view('templates/header', $data); $this->load->view('news/index', $data); $this->load->view('templates/footer'); } public function view($slug) { $data['news_item'] = $this->news_model->get_news($slug); if (empty($data['news_item'])) { show_404(); } $data['title'] = $data['news_item']['title']; $this->load->view('templates/header', $data); $this->load->view('news/view', $data); $this->load->view('templates/footer'); } public function create() { $this->load->helper('form'); $this->load->library('form_validation'); $data['title'] = 'Create a news item'; $this->form_validation->set_rules('title', 'Title', 'required'); $this->form_validation->set_rules('text', 'text', 'required'); if ($this->form_validation->run() === FALSE) { $this->load->view('templates/header', $data); $this->load->view('news/create'); $this->load->view('templates/footer'); } else { $this->news_model->set_news(); $this->load->view('news/success'); } } } Hope you find it useful. Bye
-
Thank you very very much Mahngiel. Its been solved. I altered my config file and that caused a major problem even after i have used the format you provided. On the config file, $config['base_url'] = 'localhost'; and here i had $config['index_page'] = 'home.php'; but on seeing the error it gave me i knew there was a problem from there so i changed: $config['base_url'] = ''; and $config['index_page'] = 'index.php'; and it did the magic plus the format you showed me. thanks a zillion dozen times
-
This is my header.php file and how i linked it. its not linking to the page: <div align="center"><a href="<?php echo('index.php/home') ?>">Home</a> <a href="<?php anchor('index.php/about') ?>">About</a> <a href="#">Company</a> <a href="#">Tutorials</a> </div> pls how do i resolve this? i used two methods there; the echo and anchor but to no avail thanks
-
on the header I have a couple of navigation: home about. contact. etc. how do I link them to corresponding pages.
-
hi, pls how can I add links in codeigniter? do I need to create a method in the controller? I have a header that contains navigation with links. thanks
-
The image to be uploaded is limited to a passport size photograph. the user fills a form containing his/her data and browse for a passport in the area provided and clicks upload, he sees the passport in the area meant for passport and then clicks submit so that the data gets to the database. the admin on the other hand queries for a user and gets the data of the specific query including a view of the image. <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="69%" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="13%">Name:</td> <td width="29%"><input name="name" type="text" id="name" /></td> <td width="58%" rowspan="5" valign="top"><table width="38%" height="118" border="1" cellpadding="0" cellspacing="0"> <tr> <td align="center">Passport</td> </tr> </table></td> </tr> <tr> <td>Sex:</td> <td><select name="select"> <option selected="selected">Sex</option> <option>Male</option> <option>Female</option> </select> </td> </tr> <tr> <td>Email:</td> <td><input name="emal" type="text" id="emal" /></td> </tr> <tr> <td>Address:</td> <td><input name="address" type="text" id="address" /></td> </tr> <tr> <td>Phone:</td> <td><input name="phone" type="text" id="phone" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="file" name="file" /> <input name="Upload" type="submit" id="Upload" value="Upload" /></td> </tr> <tr> <td rowspan="2"> </td> <td> </td> <td> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Submit" /> <input name="Reset" type="submit" id="Reset" value="Reset" /></td> <td> </td> </tr> </table> </form>
-
'I dont want to download image' i mean i want the image to be displayed in preview format and not like dowloading to store or something. Hope am making myself clear. Still that brings us back. How do i get it done (saving on folder and url in db) Thanks
-
yeah. i heard a person or argue about that. but i wonder which is the best practice considering bandwidth and server load? i have seen the link you gave me and thank you very much cos i got it working, but the problem is that i dont want to download the image rather i'd like when i want i can call any data and then i will see all the info for that person and then the picture included just like entering a form for school or visa lottery. thanks a great deal