-
Posts
1,200 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by divinedesigns1
-
-
hey so i been working on this website and as always have to make changes to it, so now im stuck on trying to get the used price of an items if the person picked to buy the used product. but i keep on ending up with the original price all the time
can anyone give me some tips or hint on going about doing this?
if(isset($_POST['promit'])){ include "php/sql_cn2.php"; $pid = $_POST['pid']; $sql = mysqli_query($con, "SELECT usedprice, price FROM thoseproduct WHERE id='$pid'") or die('Error: ' . mysqli_error($con)); if($sql){ while($row = mysqli_fetch_assoc($sql)){ $uprice = $row['usedPrice']; $price = $row['price']; } } $wasFound = false; $i = 0; // if the cart session is empty or not set if(!isset($_SESSION['cart_array']) || count($_SESSION['cart_array']) < 1){ // if the cart is empty $_SESSION['cart_array'] = array(0 => array("item_id" => $pid, "quantity" => 1, "price" => $price, "uprice" => $uprice)); header("location: confirm.php"); }else{ // run cart if have atleast one item foreach($_SESSION['cart_array'] as $each_item){ $i++; while(list($key, $value) = each($each_item)){ if($key == "item_id" && $value == $pid){ // that item is in the cart already adject quantity array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item["quantity"] + 1, "price" => $price, "uprice" => $uprice))); $wasFound = true; header("location: confirm.php"); } } } // if no item is in the cart if($wasFound == false){ array_push($_SESSION['cart_array'], array("item_id" => $pid, "quantity" => 1)); header("location: confirm.php"); } } }
-
hey, i have create a website, e-commerce website and i ran into a problem, where the chopping cart icon or image doesnt display the total amount of items within the cart once i click the add to cart button
how do i go about doing this? i know i have to use ajax to get this done but i have zero experience with ajax
-
Is $product suppose to be string containing a product name? You can have the if statement inside the foreach loop. When it loops through and $product is equal to $items, then do something.
yes the $product gets the name from another page. and ill definitely try that, thanks Don
-
hey, i need some help, i am trying to use an array to create an dynamic statement so i can create this page no matter what the own decided to add to the database
$query = mysqli_query($con, "SELECT * FROM department ORDER BY id ASC") or die('Error: ' . mysqli_error($con)); if($query){ while($row = mysqli_fetch_assoc($query)){ $id = $row['id']; $name = $row['name']; $list[] = $name; $detail = $row['description']; $department = $row['type']; } } foreach($list as $items){ $items = strtolower($items); echo $items . '<br>'; } if($product == $items){ }
ok so the above codes, get all the information for me, which i need, it then add the name only to the array list[]. after that i used the foreach function to convert the array, and remove all uppercases to lowercases.
now for the last statement it suppose to create an if statement which it compares the items, to the $product and if it does then it does something. but this is the part i need help with.
how do i go about getting this done? any tips or hints?
-
how do i go about getting the lowest price from the database?
it was solve, imma use the min() function to get it done
-
hey i keep on having vertical spaces, between my divs that doesnt contain no <p> tags, i have margin and padding set at 0. been googling a solution for a while now. any advice would be helpful
issue solve, went over my codes and i notice i had min-height:100% else where, which now im not sure why it should matter if i have move than one min-height for the website main div and another secondary div
-
error issue
in PHP
It's best if you use prepared statements, which completely remove the need to sanitize the data, as stated here: http://php.net/manual/en/mysqli.real-escape-string.php#102639
You can't use a string escape to sanitize numbers, for example.
thats what im using, maybe i shouldnt use sanitized to describe the use of mysqli real escape string
-
error issue
in PHP
You shouldn't have to escape quotes. Use the features built into the database library to handle sanitizing the data. What database library are you using?
i sanitized it and that worked
-
error issue
in PHP
You shouldn't have to escape quotes. Use the features built into the database library to handle sanitizing the data. What database library are you using?
mysqli
-
error issue
in PHP
so i keep getting this error, i try to escaping the double and single quotes but nothing seem to be working but if i remove the single and double quotes myself it gets save no problem
Errors: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's G-Shock anti-magnetic X-Large G watch features a 51mm wide by 17mm thick black' at line 1
this is the code im using to escape the single and double quotes
$detail = str_replace('"','"',$detail);$detail = str_replace("'","'",$detail);
any tips or hint will be useful
-
how would i go about getting specific words from the database once im using the query or after i full the information from the query
like if i have "Big Sales On Wednesday Join Us Now" but i only want "Sales On Wednesday" how do i go about doing this?
im at a blank at the moment
problem was fixed with explode() + its limit
if there's another way of doing this let me know
-
how would i go about getting specific words from the database once im using the query or after i full the information from the query
like if i have "Big Sales On Wednesday Join Us Now" but i only want "Sales On Wednesday" how do i go about doing this?
im at a blank at the moment
-
you are checking mime type against extension, 'image/gif' is mime type you need to use pathinfo($target_file,PATHINFO_EXTENSION); to retrieve extension as used here http://www.w3schools.com/php/php_file_upload.asp
wooot wooot it working thank you guys,
dsonesuk and justsomeguy -
you are checking mime type against extension, 'image/gif' is mime type you need to use pathinfo($target_file,PATHINFO_EXTENSION); to retrieve extension as used here http://www.w3schools.com/php/php_file_upload.asp
wooot wooot it working thank you guys,
dsonesuk and justsomeguy -
And if you print the value you're checking, and the values in the array, what do you find?
getting a boolean of false once i upload a jpg, etc but boolean of true once i upload a txt or doc file
when i var_dump() the $ptype i get this once i try to upload a doc or txt file
string 'application/octet-stream' (length=24)
and i get this once i try to upload the correct file
string 'image/gif' (length=9)
so im not sure how the file isnt being stopped once i try to compare it to the array
-
So, what are you doing to figure out the problem? Are you verifying anything at all or just trying to guess why it doesn't work?
actually i went around a few ways to figure out $ptype is holding any value, also i echo out $ptype, i used the $allowed array to select each value one by one $allowed[0], etc.
i have even tried the foreach()
different if statements and now im about to do var_dump and print_r
-
If $ptype matches what is in the array yes, if not you have make what is in array matches what $_FILES['imgs']['type']; returns.
thats the thing, i tried that and it still doesnt give out the correct respond
-
You are looking for something like this
$ptype = "JPG"; $errors = array(); //$ptype = "bmp"; //test by uncommenting// this is the formats $allowed = array('png', 'jpg', 'jpeg', 'jpe', 'gif');// if the format doesnt match display this if (!in_array(strtolower($ptype), $allowed)) { $errors[] = '<br>This format isnt allow</br>Accepted formats are as followed: PNG, JPG, JPEG, JPE, GIF'; } foreach ($errors as $error) { echo $error; }
so that should work even with this
$ptype = $_FILES['imgs']['type'];
-
???????? Why have repeated in another topic?
ok, so im using the in_array() dont i have to use it against the variable im checking for?
-
???????? Why have repeated in another topic?
i forgot i made this topic
-
ok im having this issue with the format that is in an array() when comparing it to the $_FILES type
$allowed = array('png', 'jpg', 'jpeg', 'gif');if($ptype != $allowed){ $errors[] = 'This format isnt allow</br>Accepted formats are as followed: PNG, JPG, JPEG, GIF';}
when i try to upload a .tiff, .doc, .txt file it still upload but once i upload the correct file it displays the error message
any tips, hint, advice on how i can go about fixing this?
-
Is there any kind of criteria for which item to show or just any item? The lazy way would be to send one query that gets the distinct department IDs, and then loop through those and send a query to get 1 row with each department ID. A more complex way would be to use a join or subquery where you get the distinct list and then join it with the same table.
the complex way sound more promising than the lazy way
-
hey dds1, do you mean you have one database and inside this database you have 3 tables x, y, and z?
correct Don E.........you name is common in anime
-
ok, i think im going in too deeply here, but i would like to accomplish this as an achievement and as a learning process.
i have 3 tables in my database at the moment, these database are x, y, z. i would like the database Y, which holds all the items and department numbers to display 1 or 2 of each items within those departments.
how do i go about doing this? any tips? hint? or advice?
responsive website giving major issues
in CSS
Posted
So i have been editing this website over and over again from resolution 240px to 1680px and it looks great on my desktop but soon as i place it online it keep on messing up the placement for certain divs on the website.
can someone take a look and let me know what the H im doing wrong?
www.divinedesigns1.net