|
Hi i have a problem with my shopiing cart i hope you can help me with my problem.
I have a shopping cart which contains a session that i get when selecting values on database.
I have also a textbox which contains a desired budget.
My problem is I want to have a error message which can detect if the total price of the session is greater than the budget.
here is my code I hope you can help me
<form method="get">
<table>
<tr>
<td style="padding:5px;">Budget:</td>
<td style="padding:5px;"><input type="text" name="budget" class="txtfield" placeholder="Please enter your desired budget"></td>
</tr>
<tr>
<td style="padding:5px;">Service Type:</td>
<td style="padding:5px;">
<select name="servicetype" class="txtfield">
<option>Wedding</option>
<option>Debut</option>
<option>Birthday</option>
</select>
</td>
</tr>
<tr>
<td style="padding:5px;"></td>
<td style="padding:5px;"><input type="submit" name="search" value="Search" class="btn btn-warning"></td>
</tr>
</table>
</form>
<?php if(isset($_GET['search'])):?>
<h3 style="background:red; color:white; width:300px; padding:5px;">Desired Amount: <?php echo $_GET['budget'] ?></h3>
<?php endif?>
<div class="products">
<?php
$current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
if(isset($_GET['search']))
{
$servicetype = $_GET['servicetype'];
if($_GET['budget'] =="")
{
echo'<div class="alert alert-warning">Please enter your desired amount</div>';
}
else
{
$servicetype = $_GET['servicetype'];
$results = $mysqli->query("SELECT service_inclusion,price,servicetype,soid FROM service_offer
where servicetype='$servicetype' ORDER BY soid ASC");
if ($results)
{
while($obj = $results->fetch_object())
{
echo '<div class="product">';
echo '<form method="get" action="cart_update.php">';
echo '<div class="product-content"><h3>'.$obj->service_inclusion.'</h3>';
echo '<div class="product-desc">Price: '.$currency.$obj->price.' </div>';
echo '<div class="product-desc">Service Type: '.$obj->servicetype.' </div>';
echo '<div class="product-info">';
echo '<button style="background:#F01818; color:white;border:0;">Add Services</button>';
echo '</div></div>';
echo '<input type="hidden" name="service_inclusion" value="'.$obj->service_inclusion.'" />';
echo '<input type="hidden" name="type" value="add" />';
echo '<input type="hidden" name="soid" value="'.$obj->soid.'" />';
echo '<input type="hidden" name="return_url" value="'.$current_url.'" />';
echo '</form>';
echo '</div>';
}
}
}
?>
</div>
<div class="shopping-cart">
<h2>Your Shopping Cart</h2>
<?php
if(isset($_SESSION["products"]))
{
$total = 0;
echo '<ol>';
if($_GET['budget'] > $cart_itm['price'])
{
$message = 'error';
}
else
{
foreach ($_SESSION["products"] as $cart_itm)
{
echo '<li class="cart-itm">';
echo '<span class="remove-itm"><a href="cart_update.php?removep='.$cart_itm["code"].'&return_url='.$current_url.'">×</a></span>';
echo '<h3>'.$cart_itm["name"].'</h3>';
echo '<div class="p-price">Price :'.$currency.$cart_itm["price"].'</div>';
echo '</li>';
$subtotal = ($cart_itm["price"]);
$Total = ($total + $subtotal);
}echo'</ol>';
echo '<span class="check-out-txt"><strong>Total : '.$currency.$Total.'</strong> <a href="view_cart.php">Check-out!</a></span>';
echo '<span class="empty-cart"><a href="cart_update.php?emptycart=1&return_url='.$current_url.'">Empty Cart</a></span>';
} }
else
{
echo 'Your Cart is empty';
}}
?>
</div>
<div style="clear:both;"></div>
</div>
<script type="text/javascript">
<?php
if(isset($message))
{
echo "alert('$message')";
}
?>
</script>
modified 13-Feb-15 4:49am.
|
|
|
|
|
You should edit the above question, remove all the code not relevant to the issue, and show exactly where the problem occurs.
|
|
|
|
|
Hi,
the following file has dateFrom and dateTo datepickers:
http://www.mybluefile.com/new_leave.zip[^]
When submitting the form I don't get the correct MySQL format therefore it's throwing an error.
The value I get is something like this:
1423900800
that's when I try:
echo $timestamp = strtotime($_POST['dateFrom']);
can you help please...
Technology News @ www.JassimRahma.com
|
|
|
|
|
strtotime converts a date string to a Unix timestamp: http://php.net/manual/en/function.strtotime.php[^]
php.net says: The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC)
To format the date, use the date function:
$timestamp = strtotime($_POST['dateFrom']);
$formatted_date = date("[format here]", $timestamp);
I don't know which format you want exactly, so you can take a look at the PHP manual to see how you can format your date:
http://php.net/manual/en/function.date.php[^]
The quick red ProgramFOX jumps right over the Lazy<Dog> .
|
|
|
|
|
Hi,
I would like to ask how to convert this C# code into PHP as my office application is in WinForm C# but need to have a PHP portal for it?
public string HashString(string toHash)
{
using (SHA512CryptoServiceProvider sha = new SHA512CryptoServiceProvider())
{
byte[] dataToHash = Encoding.UTF8.GetBytes(toHash);
byte[] hashed = sha.ComputeHash(dataToHash);
return Convert.ToBase64String(hashed);
}
}
public string HashPassword(string password, string salt)
{
string combined = password + salt;
return HashString(combined);
}
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
I am overwriting the session cookie to set different domain names with respect to the protocol(http/https)
i wanted to know whether the following is good comparing to the next
$sessname = session_name();
setcookie($sessname, $_COOKIE[$sessname], ...
vs
setcookie(session_name(), session_id(), ....
which one to use?
|
|
|
|
|
When I upload files to localhost, it runs ok. When I upload to real server and connect to it, here is what I get:
Apache 2.
Apache was not able to cross-connect to remote host.
Ive even reinstalled LAMP. With no luck
|
|
|
|
|
Hi
I am running OpenSuse
I am have flash drive on my laptop which I would like to read the contents.
I am guessing it's one of the SDXX directories in the /dev directory.
I have tried to mount each and every sda device (I have sda, sda1,sda2,sda3) and none of those seem like the flash drive
When I do a lsusb command I can see the device listed as bus 3 device 3
Any help appreciated
Thanks
|
|
|
|
|
ForNow wrote: I have tried to mount each and every sda device (I have sda, sda1,sda2,sda3) and none of those seem like the flash drive
sda will almost certainly be the HDD of you laptop with sda1 being the first partiton and sd12 the second and so on.
I would have a look at sdb and /or sdc. Haven't worked with OpenSuse, but if you're use a GUI you should be able to see the USB drive from one of the graphical programs.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
Hi all,
I have got 4 drop down selection boxes.The idea is to be able to select an item from each selection box,get them strung together in sql string and get the result of the query printed
The problem is I keep getting the following message:
Parse error: syntax error, unexpected '$rs' (T_VARIABLE) in C:\xampp\htdocs\dreamincode.php on line 60
I know the code is not too sophisticated but it's part of a little project I started earlier this year and then got distracted and just managed to get back to it now.
Here is the code in full.Any suggestions greatly appreciated.
<pre lang="xml"><!DOCTYPE HTML>
02 <html>
03 <body>
04
05
06 <select name = "author">
07 <option value="kendavies">ken davies</option>
08 <option value="arthursmith">arthur smith</option>
09 <option value="gillrafferty">gill rafferty</option>
10 <option value="mollybrown">molly brown</option>
11 <option value="gilbert riley">gilbert riley</option>
12 <option value="colinwilson">colin wilson</option>
13 <option value="jamesgreen">james green</option>
14 <option value="arnoldlaing">arnold laing</option>
15 <option value="cathyellis">cathy ellis</option>
16 <option value="carolreed">carol reed</option>
17
18 </select>
19
20 <select name = "publisher">
21 <option value="yonkers">yonkers</option>
22 <option value="blueparrot">blue parrot</option>
23 <option value="zoot">zoot</option>
24
25 </select>
26 <select name = "published">
27 <option value="2003">2003</option>
28 <option value="2004">2004</option>
29 <option value="2005">2005</option>
30 <option value="2006">2006</option>
31 <option value="2007">2007</option>
32 <option value="2008">2008</option>
33
34 </select>
35
36 <select name = "genre">
37 <option value="adventure">adventure</option>
38 <option value="thriller">thriller</option>
39 <option value="crime">crime</option>
40 <option value="biography">biography</option>
41 <option value="romance">romance</option>
42
43 </select>
44 $aa = "author"
45 $bb = "publisher"
46 $cc = "yearpublished"
47 $dd = "genre"
48 </body>
49 </html>
50 <?php
51
52 $aa = "author";
53 $bb = "publisher";
54 $cc = "yearpublished";
55 $dd = "genre";
56 mysql_connect ("localhost","root","") or die(mysql_error());
57 mysql_select_db ("authors") or die(mysql_error());
58
59 $strSQL = SELECT * FROM `books`WHERE author = '".$aa."' AND publisher = '".$bb."' AND yearpublished = '".$cc."' AND genre ='".$dd."'" ";
60 $rs = mysql_query($strSQL);
61
62
63
64 while($row = mysql_fetch_array($rs) ) {
65
66 print $row ['ID']."<br/>";
67 print $row ['author']."<br/>";
68 print $row ['booktitle']."<br/>";
69 print $row ['publisher']."<br/>";
70 print $row ['yearpublished']."<br/>";
71 print $row ['genre']."<br/>";
72 print $row ['copiessold']."<br/>";
73
74
75 }
76 mysql_close();
77 ?>
78 </body>
79 </html>
kind regards
col
|
|
|
|
|
Looks like you are missing the opening double quote before SELECT and a missing space before WHERE . I should go through the syntax for that statement again. You could check the final string by displaying it on the page before you try to execute it.
|
|
|
|
|
Hi Richard,
Many thanks for your reply.Tried all of your suggestions(and a few more variations)but to no avail.Here is an odd thing I changed the name of the $rs variable to $aaa,but strangely when I get the e Error up still refers to that variable as $rs..this makes me think that the error is still somewhere in the SELECT line.I will keep at it
Again many thanks for your reply
Kind regards
Colin
st
|
|
|
|
|
Are you sure you saved the modified version of the code before running it? If it still says "$rs" then it must be using the version before you changed the name. It is almost guaranteed that you have some mismatched quotes in your SELECT string.
|
|
|
|
|
I have a table has two columns one which show a dropdown field for no of rooms (1,2,3 ) and the other which shows the price of the room selected with total nights ( EGP 200 ) i have this code but its not working well, can someone help me? :
>
check_in_date) && !empty($this->check_out_date)) {
$room_info = $room_db->getAvailableRooms($room_type_info['id'], $this->post_search_info);
$pprice = $room_info[0]['total_price'];
?>
$(document).ready(function() {
$("#target").kendoTooltip({
autoHide: false
});
});
getShortName() . ' ' .''. $this->escape($pprice).''; ?>
Show prices
>
check_in_date) && !empty($this->check_out_date)) {
?>
0
$room_info_arr) {
$price_sum = $this->price($this->escape($room_type_info['descount_price']));
$per_night_price_sum += $price_sum;
$selected = ($this->postValues['apartments_no' . $count] && in_array($room_info_arr['room_id'], $this->postValues['apartments_no' . $count]) ) ? 'selected="selected"' : '';
if(!$this->postValues['apartments_no' . $count] && $room_info_key == 1){
$selected = 'selected="selected"';
}
$room_id_value .= (empty($room_id_value)) ? $room_info_arr['room_id'] : ',' . $room_info_arr['room_id'];
$price += $room_info_arr['total_price'];
//$selected =
echo '' . $room_cnt . '';
$room_cnt++;
}
}
?>">
|
|
|
|
|
I am new in LAMP. I want to run a simple web app running python using Django and some good interface like mod_wsgi. I have googled a lot but I am not succesful. Please give me step by step process to do it. Please suggest appropriate server.
I am using windows 7.
|
|
|
|
|
Member 9493720 wrote: Please give me step by step process to do it. No one is likely to do that on a programming forum. You need to find some tutorials and samples for yourself and start studying the systems you want to use.
|
|
|
|
|
I am looking to build a portfolio of code samples that can show what I can do as a developer. However, I am not sure what types of things I can program. What are some projects that are relatively short to medium that I can build to help build a portfolio of code samples? I know people suggest having something that shows off knowledge in OOP but other than that I'm not sure what I can create. Thanks.
|
|
|
|
|
Brandi Boseman wrote: I am not sure what types of things I can program.
Brandi Boseman wrote: I'm not sure what I can create.
There seems to be a problem with your approach.
Have you done any coding? Share sample functions. It does not have to be anything big or long. Whoever ends up caring about the portfolio won't go through it in great detail anyway so show that you know the common way of naming variables and functions, that you can use proper looping techniques, that you don't waste lots of processing time, that your code is readable, comments are effective, etc, etc.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Yes I have, but the majority of it is either stuff for my day job ( which is owned by them and can't go in a portfolio ) or stupid things that don't show off my skill as a developer. the only think i have added to some code samples are a tic tac toe class which can handle a game of tic tac toe up to 10 squares and a function that will solve a text string equation ( if you put in " ( 5 + 3 ) / 3 - 2 it will give you the right answer. accounts for parentheses, exponentials etc but i feel like those aren't "enought"
|
|
|
|
|
The first thing anyone will/should care about is your experience. You say you have "skill as a developer" so I assume you have been doing this for a fair while.
Why create a portfolio then?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
i only ask because for job interviews a lot of employers want to see a code sample, but without any constraint or basis of what type of code sample they want to see i have no clue what to send them. i sent one out and they said my code work looked like i was more suited for a "junior" position, that was a user class which managed users, it had functionality to check to see if a user was logged in, logged out a user, create a new user including generating a password hash, logging in a new user, checking to see if a user was verified etc. standard functions. i used oop principles since that was done for a job that assigned a project to me that specifically said it had to be object oriented, and had member private, with accessor classes for things that needed to be accessed from outside the class.
i've been doing professional web development for 8 years now, my current job we use cakephp framework or wordpress depending on the site. i'm just perplexes as to what would be something good. the feedback i have gotten from my code samples was that i didn't look like i was up to the level they needed, ok, well what type of code sample do you want, what are you looking for, etc? if you give me a task i can do it, but if you say "show me code" i have no clue what to give you. i can show you plenty of code...
|
|
|
|
|
OK, that makes sense.
1. It may be worth you posting some of the samples you have provided so that people here can provide feedback and perhaps more up to date approaches. I have seen developers that worked 10+ years yet their approach was still juvenile such as not using more modern features of the language.
2. I see your dilemma and perhaps the LAMP world is different than the Microsoft world, but if you have programmed for 8 years I wouldn't care about code samples, I'd want to hear you talk through challenges and projects you have worked on. As a hiring manager, I'd learn much more by listening to you than by looking at code samples.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks. I've done that too ( showing it to other coders to get input ) I wish more hiring managers would take your approach, as the random-code-sample is a bit hard
|
|
|
|
|
Hi,
I am starting with Slideshare and trying to do a basic search using the below code but all I am getting is a blank page. why?
<?
function search($query)
{
$url="http://www.slideshare.net/api/2/search_slideshows";
$api_key="xxxxxxx";
$secret_key = "xxxxxxx";
$hash = hash('sha1',$secret_key.$time);
$lang="en";
$req = $url ."?api_key=".$api_key
."&hash=".$hash
."&q=".$query;
echo $req;
$xml = simplexml_load_file($req)
or die();
var_dump ($xml);
}
$query = "PHP";
echo search($query);
?>
Technology News @ www.JassimRahma.com
|
|
|
|