i have try to use the webservice from some site,
i use nusoap library and my php code like this
<?php
require_once('lib/nusoap.php');
$client = new SoapClient("http://simlitabmas.dikti.go.id/ws_pimnas/ws.svc?wsdl");
$err = $client->getError();
if ($err) {
echo '<h2>errorr BOSSSS </h2><pre>' . $err . '</pre>';
}
$param = "examplekeyword";
$param2 = "001029";
$result = $client->call('get_peserta',array("keyword"=>"$param","kode_perguruan_tinggi"=>"$param2"));
if (!empty($result)) {
echo "<table border=1>";
echo "<tr bgcolor='#cccccc'>";
echo "<th>Name</th>";
echo "<th>Nomor Mahasiswa</th>";
echo "</tr>";
foreach ($result as $item) {
echo "<tr>";
echo "<td>".$item['nama']."</td>";
echo "<td>".$item['nomor_mahasiswa']."</td>";
echo "</tr>";
}
echo "</table>";
}
?>
The function get_peserta has two parameter to input.
when i test my php code i got blank page. Any help?
Using the WSDL from http://simlitabmas.dikti.go.id/ws_pimnas/ws.svc?wsdl, you could generate the corresponding package from wsdltophp.com in order to be sure on how to structure your request in PHP as every element will be a PHP object with setters/getters. Let me know if you need any additional help,
Related
I'm trying to create a dynamic header on Name which gives the user the ability to sort by ASC or DESC, the results is from the 'register'-table in MySQL. I have tried a couple of codings, but it hasn't given the correct result as of now. Hope anyone is able to help me :)
I have tried making another variable, but I couldn't manage to create the correct one.
<?php
$sql = "SELECT * FROM register";
if($sqlData = mysqli_query($db, $sql)) {
if(mysqli_num_rows($sqlData) > 0) {
echo "<table border ='1' bgcolor='#FFF' width='100%'>";
echo "<tr>";
echo "<th><a href='overview.php?order=name'>Name</a></th>";
echo "<th>Score</th>";
echo "</tr>";
while($row = mysqli_fetch_array($sqlData)) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['score'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_free_result($sqlData);
} else{
echo "No results in DB";
}
} else{
echo "Error couldn't connect $sql. " . mysqli_error($db);
}
mysqli_close($db);
?>
Hm, that's not a good idea to sort table using MySQL each time user clicked on the table's header.
I suggest you to use javascript for it. Example
I am currently working on a PHP and SQLite application. It does have HTML for the webpages being created. I am currently using PDO to connect the database to my online server. When I get to the webpage that allows me to type in what I am searching for then it will display what I have found in the echo statements below. I want to be able to have just the item name, that acts as a hyperlink; when it is clicked on it will go to another webpage (I believe) that will display the item's name, amount, and a short description. Is there a way to use PHP for this action or should I go with the HTML tagging?
if($_POST && isset($_POST['search'])) {
echo "<br>\n";
$query = $mysql->prepare('SELECT * FROM Items WHERE Name = :partname');
$subst = array ('partname' => $_POST['search']);
$query->execute($subst);
echo "<TABLE>";
echo "<tr>";
echo "<td>Name</td>";
echo "<td>Amount</td>";
echo "<td>Detail</td>";
echo "</tr>";
while ($row = $query->fetch()) {
//print_r($row);
echo "<tr>";
echo "<td>$row[Name]</td>";
echo "<td>$row[Amount]</td>";
echo "<td>$row[Detail]</td>";
echo "</tr>";
}
echo "</TABLE>";
} else echo "Item searched for was not found.";
from what i understand
if($_POST && isset($_POST['search'])) {
echo "<br>\n";
$query = $mysql->prepare('SELECT * FROM Items WHERE Name = :partname');
$subst = array ('partname' => $_POST['search']);
$query->execute($subst);
echo "<TABLE>";
echo "<tr>";
echo "<td>Name</td>";
echo "</tr>";
while ($row = $query->fetch()) {
//print_r($row);
$name = $row['Name'];
echo "<tr>";
echo "<td><a href='details.php?name={$name}'>{$name}</a></td>";
echo "</tr>";
}
echo "</TABLE>";
} else echo "Item searched for was not found.";
To use Associative Arrays within double quotes, you need to use curly braces:
echo "<td>{$row['Name']}</td><td>{$row['Amount']}</td><td>{$row['Detail']}</td>";
I am developing an application in codeigniter.In my application there is a need to integrate with Google search.In my application there is a textbox and a submit button,If the user searches something it will search the data in google and display the result in my page. How can i do it?Any idea from anyone.
I've successfully used,
<?php
$query = "Steve Jobs";
$api_url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&&rsz=large&q=".$query;
$body = file_get_contents($api_url);
$json = json_decode($body);
for($x=0;$x<count($json->responseData->results);$x++)
{
echo "<b>Result ".($x+1)."</b>";
echo "<br>URL: ";
echo $json->responseData->results[$x]->url;
echo "<br>VisibleURL: ";
echo $json->responseData->results[$x]->visibleUrl;
echo "<br>Title: ";
echo $json->responseData->results[$x]->title;
echo "<br>Content: ";
echo $json->responseData->results[$x]->content;
echo "<br><br>";
}
In Codeigniter you can create a helper function (if to be used many times) for this,
applications/helpers/google_helper.php
<?php
function google_search($query)
{
$api_url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&&rsz=large&q=".$query;
$body = file_get_contents($api_url);
return json_decode($body);
}
im trying to retrieve data from database and display it into a table in php
i tried this
<?php
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
mysql_query("SET NAMES 'utf8'");
// get all products from products table
$result = mysql_query("SELECT *FROM glossary") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["glossaries"] = array();
echo "<table>";
echo "<tr>";
echo "<th>Symbol</th>";
echo "<th>Name</th>";
echo "<th>Description</th>";
echo "<th>Chapter</th>";
echo "</tr>";
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>". $row['Symbol'] ."</td>";
echo "<td>". $row['Name'] ."</td>";
echo "<td>". $row['Description'] ."</td>";
echo "<td>". $row['ID_Chapter'] ."</td>";
echo "</tr>";
}
echo "</table>";
header("Content-type: application/json; charset=utf-8");
// success
$response["success"] = 1;
// echoing JSON response
} else {
// no products found
$response["success"] = 0;
$response["message"] = "No products found";
}
?>
but i will get a really strange result in the browser it will print the table tags td,tr... and the value between them like this:
<table><tr><th>Symbol</th><th>Name</th><th>Description</th><th>Chapter</th></tr><tr><td>θ </td><td></td><td></td><td>8</td></tr><tr><td>A ⊂ B</td><td>Proper subset / strict subset</td><td>Subset has fewer elements than the set</td><td>1</td></tr><tr><td>A'</td><td>Complement </td><td>Event A does not occur</td><td>1</td></tr></table>
why ?
header("Content-type: application/json; charset=utf-8");
That's... not JSON data. That's HTML. For example:
echo "<table>";
The default Content-type is probably HTML, so you can just remove the header line entirely. If you want to be explicit, you can be:
header("Content-type: text/html; charset=utf-8");
Basically what's happening is that you're explicitly telling the browser not to render the HTML, but to just treat it like JSON data. Which is why it's not rendering the HTML.
I am really confused, a script of mine works perfectly in wamp but when i try to run it in my ubuntu apache2 server i get a blank page as output, the same thing happens when i uploaded it to a webserver and executed the script.
I could pinpoint that the error is caused due to the presence of this line of code
while ($row = mysql_fetch_assoc($result))
even if i comment it out the problem persists, only deleting this line will allow me to get any kind of output. Even a simple echo wont work if this line is present.
I am posting the whole script, below may be you people can help me understand the reason behind this strange behavior.
<?php
session_start(); // start up the PHP session!
//Connect to mysql
include 'conn.php';
// Table name
$tbl_name = "tailor.employee";
//Get and initialize variables
$op = $_POST['op'];
$cusid = $_POST['cusid'];
if($op=="2")
{
$sql = "SELECT * FROM tailor.order WHERE cusid ='$cusid'";
$result = mysql_query($sql);
// Mysql_num_row is counting table row
$count = mysql_num_rows($result);
if($count!=0)
{
$order = array();
$oid = array();
$day = array();
$month = array();
$year = array();
$quan = array();
$i=0;
while ($row = mysql_fetch_assoc($result)) {
$cusid = $row['cusid'];
$cname = $row['cname'];
$phone = $row['phone'];
$order[$i] = $row['type'];
$oid[$i] = $row['oid'];
$day[$i] = $row['day'];
$month[$i] = $row['month'];
$year[$i] = $row['year'];
$quan[$i] = $row['quan'];
$i=$i+1;
}
echo "<br><br><br><br><br><br>";
echo "<pre><p><strong>Customer ID : </strong>".$cusid."</pre></p>";
echo "<pre><p><strong>Customer Name : </strong>".$cname."</pre></p>";
echo "<pre><p><strong>Phone Number : </strong>".$phone."</pre></p>";
echo '<table border="1">';
echo "<tr>";
echo "<td>Quantity</td>";
echo "<td>Order ID</td>";
echo "<td>Particulars</td>";
echo "<td>Delivery Date</td>";
echo "</tr>";
echo "<tr><td>";
$icount = count($oid);
for($k=0;$k<$icount;$k++)
{
echo $quan[$k];
echo "<br>";
}
echo "</td>";
echo "<td>";
for($k=0;$k<$icount;$k++)
{
echo $oid[$k];
echo "<br>";
}
echo "</td>";
echo "<td>";
for($j=0;$j<$icount;$j++)
{
echo $order[$j];
echo "<br>";
}
echo "</td>";
echo "<td>";
for($l=0;$l<$icount;$l++)
{
echo $day[$l]."/".$month[$l]."/".$year[$l];
echo "<br>";
}
echo "</td>";
echo "</tr>";
echo "</table>";
echo '<br><br><p ALIGN = "center">Place New Order</p>';
}
unset($_SESSION['cusid']);
unset($_SESSION['oid']);
unset($_SESSION['type']);
unset($_SESSION['cname']);
unset($_SESSION['phone']);
unset($_SESSION['address']);
}
if($op=="1")
{
header('location:order1.html');
}
?>
The app is live and can be accessed by visiting http://www.techb.wilips.com/login.html
The login user name is modern and password is modern#123
To view the error page, just login, add an order and follow the steps then on the 3rd step where you have the Operation drop down menu, select Print Order