|
is it possible to make INSERT all checkbox values into database when there is not even one checkbox being checked since im using array_diff as shown below?
my problem currently facing is,
when there is a checkbox being checked, it will insert into checked_table and the remainder options which did not selected will insert into unchecked_table.
howewer, when all checkbox didnt being selected, and click on submit button, the value didnt send to my database unchecked_table.
<pre lang="PHP"><?php
include('connect.php');
$checked = ($_POST['date']);
$unchecked = ($_POST['nondate']);
$diff = array_diff($unchecked,$checked);
if(isset($_POST['date']))
{
foreach ($_POST['date'] as $dateValue)
{
$insert="INSERT INTO checked_table ($colm_ladate) VALUES ('$dateValue')";
mysql_query($insert);
}
echo header("location:home.php");
}
if (isset($_POST['nondate']))
{
foreach ($diff as $dateValue2)
{
$insert2="INSERT INTO unchecked_table($colm_lrdate) VALUES ('$dateValue2')";
mysql_query($insert2);
}
echo header("location:home.php");
}
?>
|
|
|
|
|
how to create invoices in PHP?
|
|
|
|
|
|
but here I was a beginner, who just understand the basic of PHP
|
|
|
|
|
Then go and buy a book and study it, or find some online courses. It is not possible to provide an answer to such a broad question.
|
|
|
|
|
I Need to create this XML using PHP:
<con:ContractOptions>
<con:ContractOption>
<con:Id>49</con:Id>
<con:Description>Diesel/Turbo</con:Description>
<con:IsSurcharge>false</con:IsSurcharge>
<con:NetCost>150.00</con:NetCost>
</con:ContractOption>
<con:ContractOption>
<con:Id>50</con:Id>
<con:Description>AWD/4WD</con:Description>
<con:IsSurcharge>false</con:IsSurcharge>
<con:NetCost>100.00/con:NetCost>
</con:ContractOption>
<con:ContractOption>
<con:Id>51</con:Id>
<con:Description>Commercial Vehicle</con:Description>
<con:IsSurcharge>false</con:IsSurcharge>
<con:NetCost>75.00</con:NetCost>
</con:ContractOption>
</con:ContractOptions>
Here is the section of my PHP code to build that XML:
$ContractOptionFields = array(
"con:Id" => $OptionId,
"con:Description" => $Surcharge_Description,
"con:IsSurcharge" => $IsSurcharge,
"con:NetCost" => $OPTION_NetRate
);
$ContractOptions = array(
"con:ContractOption" => new SoapVar($ContractOptionFields, SOAP_ENC_OBJECT)
);
$arcontract = array(
"con:ContractOptions" => new SoapVar($ContractOptions, SOAP_ENC_OBJECT), ...
My code will only produce one set of contract options like this:
<con:ContractOptions>
<con:ContractOption>
<con:Id>49</con:Id>
<con:Description>Diesel/Turbo</con:Description>
<con:IsSurcharge>false</con:IsSurcharge>
<con:NetCost>150.00</con:NetCost>
</con:ContractOption>
</con:ContractOptions>
How do I build more than one option into this XML using my PHP code sample? Do I need to use a PHP for Loop? Not sure how to set this up.
Thanks for your assistance.
|
|
|
|
|
what,s the new app today that demanded using php....????
|
|
|
|
|
|
how to work on chat app by using php........plz tell the coding
|
|
|
|
|
Please do your own research, Google will find you many samples.
|
|
|
|
|
Dear All,
I have already json file that have data EmpCode and EmpName. But how can I show the data in text box on my web page.Please help me.Here are my code.
<pre lang="text">
<html>
<head>
<title>Employee</title>
<?php
function getemployee()
{
$url = "http://localhost/1004.json";
$json = file_get_contents($url);
$data=json_decode($json, TRUE);
return $data;
}
?>
</head>
<body>
<form method="post">
Emp Code:<input type=text name="text1" />
<br>
Emp Name:<input type=text name="text2" />
<br>
<input type="submit" onclick="'<?php' getemployee(); '?>'" value="Get"/>
</form>
</body>
</html>
</pre>
|
|
|
|
|
<input type="text" name="text2" value="<?
echo $json = getemployee();
$json->var
?>"/>
obj is your Variable name
use print_r(getemployee()) view json Structure;
|
|
|
|
|
Dear All,
I'm a win app programmer but a very fresher in web. Now I have to do with web, so I am studying in web with PHP. I have to figure out the problem that I want to show data from Sql Database on PHP web page via web service by generating JSON file. I don't use the internet. All are in local only. I create web page two text box and one button. I type 01 employee code in textbox1 and click the button to get employee name from sql db. There are function in web services. When the button click, PHP page will send 01 to web service and then the function in web service will get the emp name from sql db and returns json file and finally PHP page will be read json file and show emp name in textbox2. So I can't control one round procedure PHP, Web Service, JSON and Sql db. Please help me. Very thanks everyone. I hope with great wish for that. Please.
Thanks you all
|
|
|
|
|
use function to send response to browser in json format or just echo response array in json
public function send_response($response_data){
//$resonse_date is of array type
echo json_encode($response_data);
}
catch json response in ajax callback for success .
$.ajax({
url: 'php service call' ,
type : 'POST',// type of call GET ,POST
data : JSON.stringify(params),//pramas array
success :function(data) {//call back functin
//reponse data in json format
//put here your logic
},
error : function(data){alert('if any error');}
});
|
|
|
|
|
I m installed sqlserver for my final project... i wanot installed properly.. i uninstalled it.. no i m installng it again but getting the following error when i click on the icon of "SQL Server Management Studio Express".. plz help me.. i would be very thnkful to you.
"The automatically saved settings file ' C:\Users\Bilal\Documents\ SQL Server
Management Studio Expres\Settings\CurrentSettings-2014-06-18.vssettings' cannot be found.You can change this file on the 'Import and Export Settings' Tools Options Page. the IDE will use the most recent settings for this session."
|
|
|
|
|
Hi,
f anyone tried a PHP framework, which you'll recommend please?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
None!
Frameworks are good, if you get in the area of content management, otherwise they are just a waste of time.
|
|
|
|
|
Hi guys! I need your help !
I'm doing a form in PHP and a want to display in my dropdownlist name column from my DB and save the name_id of that name selected from dropdownlist in DB.
Here is my code
if(isset($_POST["submit"]))
{
$bookshop_id = mysql_real_escape_string($_POST["bookshop_id"]);
$book_id = mysql_real_escape_string($_POST["book_id"]);
$quantity = mysql_real_escape_string($_POST["quantity"]);
mysql_query("INSERT INTO `books_bookshop`(`bookshop_id`,`book_id`,`quantity`)
VALUES ('" . $bookshop_id . "','" . $book_id . "','" . $quantity . "')")
or die ("Book could not be registered.");
}
?>
<form method="post" action="#">
<label for="bookshop_id">Bookshop Name</label>
<select style="width:148px;" id="bookshop_id" name="bookshop_id" value="bookshop_id" >
<?php
$query = mysql_query("SELECT `name`,`bookshop_id` FROM `bookshop`");
while ($row = mysql_fetch_array($query))
{
?>
<option>
<?php echo $row["name"]; ?>
</option>
<?php } ?>
</select>
</td>
</tr>
<tr><td><select name="book" id="book" value="book">
<?php $query = mysql_query("SELECT `name` FROM `books`");
while ($row = mysql_fetch_array($query)){?>
<option><?php echo $row["name"]; ?></option>
<?php } ?>
</select>
<tr>
<td><input type"submit" name="submit" value="Register book"></td>
</tr>
</table>
</form>
|
|
|
|
|
<form method="post" action="#">
<label for="bookshop_id">Bookshop Name</label>
<select style="width:148px;" id="bookshop_id" name="bookshop_id" value="bookshop_id" >
<?php
$query = mysql_query("SELECT `name`,`bookshop_id` FROM `bookshop`");
while ($row = mysql_fetch_array($query))
{
?>
|
|
|
|
|
<option>
<?php echo $row["name"]; ?>
</option>
<?php } ?>
</select>
</td>
</tr>
<tr><td><select name="book" id="book" value="book">
<?php $query = mysql_query("SELECT `name` FROM `books`");
while ($row = mysql_fetch_array($query)){?>
<option><?php echo $row["name"]; ?></option>
<?php } ?>
</select>
<tr>
<td><input type"submit" name="submit" value="Register book"></td>
</tr>
</table>
</form>
|
|
|
|
|
Why have you posted three messages? It looks like you have answered your own question.
Use the Edit link at the bottom of your original, add the extra code and description, and delete the other two messages.
|
|
|
|
|
You know that mysql_ is deprecated for long, right ?
"Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
mysqli_query()
PDO::query()
"
Source
http://php.net/manual/en/function.mysql-query.php[^]
|
|
|
|
|
have a tree menu(category,subcategory,sub-subcategory...) its all in a single table and uses parentID to determine layout of the menu. would like to now be able to update the menu by adding new menus(not on the server side). have a dropdown list of the menus where you select the parent from existing menus from the table(if you select none,then creates a new category in the table else inserts under matching parent based on parentID).need help parsing the selection from drop down menu to the parentID column in the table. am new at this so hope my question makes sense.
Reggie
|
|
|
|
|
Use PHP and angularjs to generate dynamic menu.
1.php service read your data send response in json format.
2.Angular app init with menu item.
your html code like (menu.html)
<pre>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<style>
*{
margin ;
padding ;
}
body{
font:15px/1.3 'Open Sans', sans-serif;
color: #5e5b64;
text-align:center;
}
a, a:visited {
outline:none;
color:#389dc1;
}
a:hover{
text-decoration:none;
}
section, footer, header, aside, nav{
display: block;
}
/*-------------------------
The menu
--------------------------*/
nav{
display:inline-block;
margin:60px auto 45px;
background-color:#5597b4;
box-shadow 1px 1px #ccc;
border-radius:2px;
}
nav a{
display:inline-block;
padding: 18px 30px;
color:#fff !important;
font-weight:bold;
font-size:16px;
text-decoration:none !important;
line-height:1;
text-transform: uppercase;
background-color:transparent;
-webkit-transition:background-color 0.25s;
-moz-transition:background-color 0.25s;
transition:background-color 0.25s;
}
nav a:first-child{
border-radius:2px 0 0 2px;
}
nav a:last-child{
border-radius 2px 2px 0;
}
nav.home .home,
nav.projects .projects,
nav.services .services,
nav.contact .contact{
background-color:#e35885;
}
p{
font-size:22px;
font-weight:bold;
color:#7d9098;
}
p b{
color:#ffffff;
display:inline-block;
padding:5px 10px;
background-color:#c4d7e0;
border-radius:2px;
text-transform:uppercase;
font-size:18px;
}
</style>
<!-- Adding the ng-app declaration to initialize AngularJS -->
<script type="text/javascript">
var menuApp = angular.module('menuApp', []);
menuApp.controller('menuCtrl', function ($scope,$http) {
$scope.active = 'Blog';
$scope.description = ''
$scope.menuList = [
{
'name': 'Home',
'description': 'Home page.'
},
{
'name': 'Projects',
'description': 'projects page.'
},
{
'name': 'Services',
'description': 'services page.'
},
{
'name':'Contact',
'description':'contact page.'
}
];
$scope.activeMenu = function(menu){
$scope.active = menu.name;
$scope.description = menu.description;
};
$scope.loadMenu = function() {
$http({
method: 'GET',
url: 'menu.php' //url contain your php service which return data in json format
}).success(function(data) {
$scope.menuList = data;
}).error(function() {
});
}
// $scope.loadMenu();
});
</script>
<div id="main" ng-app="menuApp">
<!-- The navigation menu will get the value of the "active" variable as a class.
The $event.preventDefault() stops the page from jumping when a link is clicked. -->
<div ng-controller="menuCtrl">
<nav class="{{active}}" ng-click="$event.preventDefault()" ng-repeat="menu in menuList">
<!-- When a link in the menu is clicked, we set the active variable -->
<a href="#" class="{{menu.name}}" ng-click="activeMenu(menu)">{{menu.name}}</a>
</nav>
<!-- ng-show will show an element if the value in the quotes is truthful,
while ng-hide does the opposite. Because the active variable is not set
initially, this will cause the first paragraph to be visible. -->
<p ng-hide="active">Please click a menu item</p>
<p ng-show="active">You chose <b>{{active}}</b> </p>
<span ng-show="active"> <b>{{description}}</b></span>
</div>
</div>
</pre>
//your ajax call get response from php service while page load and populate your menu as per your choice.
|
|
|
|