...

Hi! I’m Starx

experienced Software Developer. And this is my blog
Start Reading About me
Blog Page
May 17, 2010

Results page in other window

Question by xRobot

I have this simple form:

<form method="post" action".">
<input type="text" name="title">
<input type="submit" name"send">
</form>

I want that when a user click on submit, then will be open another window of browser with the results. Is it possible ?

Answer by andr

If you just need to open a new window:

<form method="post" action="..." target="_blank">
...

If you want a popup or lightbox or anything scripty:

<form method="post" action="..." onsubmit="yourFunction()">

Answer by Starx

Use this

<form method="post" action"thepagetodisplay.php">
<input type="text" name="title" id="title">
<input type="submit" name"send">
</form>

on thepagetodisplay.php

extract($_POST);
echo $title;
Read more

output all data from db to a php page

Question by Sarit

I’m a real beginner with PHP & mysql.
Just for studying and for a simple example at school I would like to work this simple query and possibly output all the rows (or maybe even one) to a very basic output on a php page:

<?php
$user= "root";
$host="localhost";
$password="";
$database = "PetCatalog";
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn’t connect to server");
$query = "SELECT * FROM Pet";
$result = mysql_query($cxn,$query) or die ("Couldn’t execute query.");
$row = mysqli_fetch_assoc($result);
echo "$result";
?>

this is the error message i’ve been getting:

Warning: mysql_query() expects parameter 1 to be string, object given in C:xampplitehtdocsmyblogquery.php on line 18
Couldn’t execute query.

What should I do?
Thanks!

Answer by Starx

<?php
$user= "root";
$host="localhost";
$password="";
$database = "PetCatalog";
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn’t connect to server");
$query = "SELECT * FROM Pet";
$result = mysql_query($query) or die ("Couldn’t execute query.");
while($row = mysqli_fetch_array($result)) {
          print_r($row);
}
?>

This should solve your problem

Read more
May 12, 2010

execute javascript method after completing code behind method?

Question by James123

I want execute below callback() method after completion of document.getElementById('btnDownload').click(); method . Now callback()executing immediatly. I want wait “Click()” process done then Execute callback(); method.

function LoadPopup() {
        //  find the popup behavior
        this._popup = $find('mdlPopup');
        // show the popup
        this._popup.show();

        // synchronously run the server side validation ...
        document.getElementById('btnDownload').click();
       callback();         
    }

 function callback() {
        this._popup = $find('mdlPopup');
        //  hide the popup
        this._popup.hide();
        alert("hi");

}

Answer by Starx

Your question is not clear. But I will give you a example.

For example, you wan to load a page by clicking on a image then after the page load is complete you want to do something you can something like this

$('#buttonid').click(function() {
    //this is the callback function of click event
    //if you want some other callback functions then you need something like this
    $("#somediv").load("page.php", function() {
       //callback function code of .load event
       alert('page loaded');
       });
 });

What you are asking is to have a callback function inside the default callback function of click event and a bit impossible from my point of view.

Read more
...

Please fill the form - I will response as fast as I can!