Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. one direction you could take is something like this:

    have a select list of all users with the name as the select option and the value as the mobile:
    <select id="names">
    <option value="077451452584">Bob Bob</option>
    <option value="077451452585">Frank Frank</option>
    <option value="077451452586">Bertha Bertha</option>
    </select>
    
    <script>
    $(document).ready(function(){
    
    $('#names').on('change', function(){
       var val = $('option:selected', this).val();
       alert(val);
    });
    });
    </script>
    

  2. <?php
    /* MySQL Columns & Types
    Id - Primary Key (Index), Auto Increment - Int (11)
    Title - Varchar (20)
    FirstName - Varchar (60)
    LastName - Varchar (60)
    */

    class client
    {
    private $_mysqli;
    private $_title;
    private $_firstName;
    private $_lastName;


    //Connect to MySQL
    public function __construct()
    {
    $this->_mysqli = new mysqli("localhost", "test", "test", "test");

    if ($this->_mysqli->error) {
    throw new Exception($this->_mysqli->error);
    }

    }

    //These functions build the insert query so they can be called one at a time or all at once
    public function setTitle($title)
    {
    $this->_title = $title;
    }

    public function getTitle()
    {
    echo $this->_title;
    }

    public function setFirstName($firstname)
    {
    $this->_firstName = $firstname;
    }

    public function getFirstName($te)
    {
    echo $this->_firstName;
    }

    public function setLastName($lastname)
    {
    $this->_lastName = $lastname;
    }

    public function getLastName()
    {
    echo $this->_lastName;

    }

    public function load($client_id)
    {

    $data = array();
    //the follwoing is on the principle of a single result
    $query = "SELECT * FROM mysql WHERE id = " . $client_id;
    $sql = $this->_mysqli ->query($query);
    if($sql->num_rows > 0) {
    while ($row = $sql->fetch_assoc()) {
    $this->_title = $row['title'];
    $this->_firstName = $row['firstname'];
    $this->_lastName = $row['lastname'];

    // now you have done this you will have a populated object. so the get the firstname you do $client->getFirstname()
    }
    } else {
    throw new Exception('client not found');
    }
    }

    // you should be able to figure the rest out
    /*public function save()
    {

    if ($check->Rows() > 0) {
    //update
    $mysqli->query("UPDATE clients SET $cloumns");
    } else {
    //insert
    $query = "INSERT INTO mysql (".$columns.")VALUES (.".$values.".)";
    $mysqli->query($query);
    }
    $sql->close();

    }*/
    }
  3. Again, Irate, I am afraid that this is not really a popup, it is 2013, not 2003. people tend not to use secondary windows for popups nowadays. With the advancement in client side languages and the common use of ajax the need for this style of 'popup' is now defunct. you don't need to use onclick= within the elements any more, in fact the prefered method is not to have any javascipt in the html at all and bind an event listener to an element and inject what is needed into the DOM. below is a quick example of a jquery dialog ( popup ):

    <html>
    <head>
        <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css"></link>
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    </head>
    <body>
    <button id="myButton">Click Me To Open Dialog</button>
    
    <div id="dialog-message" title="Im the title" style="display:none">
        <div style="margin-left: 20px;">
            <p>
                Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. 
                <br /><br />
                Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. Lorem Ipsum. 
            </p></div>
    </div>
    
    <script>
        $(document).ready(function(){
            $('#myButton').on('click',function(){
                $("#dialog-message").dialog({
                    modal: true,
                    draggable: true,
                    resizable: false,
                    position: ['center', 'top'],
                    show: 'blind',
                    hide: 'blind',
                    width: 400,
                    buttons: {
                        "Click me to close dialog": function() {
                            $(this).dialog("close");
                        }
                    }
                });
    
            });
        });
    </script>
    </body>
    </html>
    

    Hope this helps

  4. irate: that is not a popup, that is a new window. if you want a popup you are more than likely referring to some form of modal dialog. Have a google for jquery modal dialog, or bootstrap dialog. that will give you a good starting point

  5. php comes with some helpful constants and methods that can help. the one you will be concerned with is :

    DIRECTORY_SEPERATOR
    // an example would be
    
    $fileDir = 'dir1'.DIRECTORY_SEPERATOR.'dir2'.DIRECTORY_SEPERATOR.......... and so on
    

    so the above would give you dir1/dir2/..... on a linux machine, and is clever enough to translate it to dir1\dir2 on windows

  6. ok, firstly, my bad. query should read:

    $sql = "INSERT INTO emails(`player_name`,`email`) values ('{$_POST['playername']}','{$_POST['email']}')";
    

    pay very close attention to the tick marks surrounding player_name and email. they have to be backticks --> ` <--- not single apostrophes -->'<--  so they should be `player_name` NOT 'player_name'

    .a varchar and text field can both accept nubmers and characters. your sql error is telling you that you have a syntax error, which is what i have described above.

  7. do 

    $sql = "INSERT INTO emails(`player_name`,`email`)('{$_POST[playername]}','{$_POST[email]}')";

    mysql_query($sql,$con) or die(mysql_error());

     

    that should give you some inkling as to whats wrong.

    Also make sure you have the primary key set to auto incriment

  8. ok firstly, jugesh is wrong, when it comes to mixing html and php on a page, if the php is not outputting ( rendering anything then it is irrelevant where it is on the page ) the reason you are getting this error is because you are manyally killing the script:

    $con=mysql_connect("localhost","dbs_dbs","password");
    die("Can not connect: " . mysql_error());

    needs to be 

     

    $con=mysql_connect("localhost","dbs_dbs","password") or die("Can not connect: " . mysql_error());
  9. And I want a big house and fast car, but i want dosent get. You want help then give more information than just i want!!

     

    What framework is the site built in? this would be a good start, or at least the section of code that deals with the routing

  10. are you running the site from / or app_dev.php? sounds like your getting a fatal error,. have you cleared the cache and updated the schema?

    php app/console cache:clear --env=dev
    php app/console doctrine:schema:update --force
    

    also look in the app/logs/dev log to see if there is any error being thrown

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