-
Posts
153 -
Joined
-
Last visited
Never
Everything posted by scmeeker
-
I want to list the contents of my table but I don't want it to keep repeating and I'm trying to stop the loop but seem to be missing something that perhaps a more experienced set of eyes can catch. When I try, it will only show one record and stop but I want it to list them all and stop. Any suggestions? Thanks. Here is the code: $get_items_sql = "SELECT id, title, location, deadline, brief_description, date FROM list WHERE MONTH(date) = MONTH(CURDATE())"; $get_items_res = mysqli_query($mysqli, $get_items_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_items_res) < 1) { $content = "<p><em>Sorry, no items in this category.</em></p>\n"; } else { $content .= "<ul>\n"; while ($items = mysqli_fetch_array($get_items_res)) { $item_url = "list_detail.php?id={$items['id']}"; $item_title = stripslashes($items['title']); $item_location = $items['location']; $item_deadline = $item_info['deadline']; $item_brief_description = $items['brief_description']; $item_id = $items['id']; $content .= ""; $content .="<table width=\"693\ height=\"300\" border=\"0\"><tr><td width=\"200\"> <a href=\"{$item_url}\"> {$item_title}</a><td width=\"251\">{$item_location}</td> <td width=\"109\">{$item_deadline}</td></tr><tr><td colspan=\"3\" valign=\"top\" class=\"blackfont\">{$item_brief_description}</td></tr></table>"; $content .= "\n"; } $content .= "</ul>\n";
-
Thanks SO much...it works perfect now. I spent hours yesterday trying to solve that between research and trial.
-
I'm having trouble getting the $item_fee variable to produce a result. When echoing, it doesn't produce anything. I would like it to add all the values under the "item_fee" column for this month and for the particular user. I would appreciate any feedback on this. I've tried it several ways with no luck. Here's the code I've written for it: $get_item_sql = "SELECT SUM(item_fee), date, username FROM product WHERE MONTH(date) = MONTH(CURDATE()) AND username = '".$_GET["username"]."'"; $get_item_res = mysqli_query($mysqli, $get_item_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_item_res) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_info = mysqli_fetch_array($get_item_res)) { $item_fee = $item_info['item_fee']; $image_fees = $item_fee * .20; Then I echo the $item_fee it to a page but have nothing come up. Any suggestions?
-
I would like to use the SUM() to add up the column 'item_fee' under the current WHERE conditions and am not having any luck. Keeps coming up blank but when I remove the SUM() it shows just one. Here is the code I'm using: $get_item_sql = "SELECT id, image_upload_box, title, username, date, price, SUM(item_fee) FROM product WHERE MONTH(date) = MONTH(CURDATE()) AND username = '".$_GET["username"]."'"; Any suggestions? Thanks.
-
Thank you!
-
Here is the code that builds the drop down menu: <select name="location" class="blackfont"> <option value="US">US</option> <option value="CANADA">CANADA</option> </select>
-
I have a drop down menu option on a form. After a user makes a selection, it goes to the next page for confirmation with the option to edit their information. On the edit page, I would like the drop down menu to go to the selection they chose. Anyone have a suggestion on how to incorporate the PHP code with this? Here is the drop down code I'm using with it: <select name="location" class="blackfont">
-
I found it: <INPUT TYPE="image" SRC="images/submit.gif" BORDER="0"> Thanks!
-
When I tried that, it came up with an input box with the "next" in it. Hmmmm...I've been playing around with it but still no luck.
-
Is it possible to have an image in place of the generic submit button on a PHP form? I know how to incorporate PHP into an image to make a link but I wasn't sure about a form submit. If so, how would I incorporate this image into this line of code? <input type="submit" name="submit" value="NEXT" /> Here is the image code: <img src=\"add_new_button.gif\" width=\"180\" height=\"43\" border=\"0\" /> Thank you.
-
I'm trying to make this URL work but I'm putting the quotes in the wrong place and I've tried several different ways. Perhaps another set of experienced eyes could help: <?php echo $display_block = "<a href=\"add_new_product3.php?id=".$_GET['id']."=success&show_image=".$_FILES["image_upload_box"]["name"]\">PREVIOUS TO EDIT</a>" ?> Thanks for your help.
-
What I did was decided to create a blank test page to pass the information to until I could get it to work. Then, when I finally did get it to pass the id, I did the same for the image upload page. With a combination of everything you said and a little tweaking...I got it to work.
-
Hallelujah! I finally got it!! Yes...it works! Thank you everyone for your help!!!!!
-
Okay, fixed that. But, now the id doesn't show up in the URL string with those changes. Hmmm...??
-
When I tried this suggestion: In the script that processes it, you need to change the assignment to $item_id = mysql_real_escape_string($_GET[id]); it came back with this error: Error: 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 '' at line 3
-
I also tested the second page (edit/update information) of the form by trying to echo the ID to a place onto the next page (image upload page) and nothing came up so that shows the variable is not being passed correctly. Strange though how it shows up in the URL.
-
Thanks. Okay...here it is: Here is the update/edit form code that comes just before that upload image page: <?php session_start(); //connect to database $mysqli = mysqli_connect("localhost", "", "", "store"); //validate item $get_item_sql = "SELECT id, title, description, price, location, ship_to, shipping_cost, international, in_shipping FROM product WHERE username = '".$_GET["username"]."'"; $get_item_res = mysqli_query($mysqli, $get_item_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_item_res) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_info = mysqli_fetch_array($get_item_res)) { $item_title = $item_info['title']; $item_description = $item_info['description']; $item_price = $item_info['price']; $item_location = $item_info['location']; $item_ship_to = $item_info['ship_to']; $item_shipping_cost = $item_info['shipping_cost']; $item_international = $item_info['international']; $item_in_shipping = $item_info['in_shipping']; $item_id = $item_info['id']; $content .= ""; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="styles/llery2.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- a:link { color: #09C; text-decoration: none; } a:visited { text-decoration: none; color: #09C; } a:hover { text-decoration: underline; } a:active { text-decoration: none; } --> </style></head> <div align="center"> <body> <div class="mainbody"> <div class="header1"><a href="http://www.ne.com"><img src="Logo.gif" width="200" height="75" border="0" /></a> <a href="galleries.php">Galleries</a> <a href="join.php">Join</a> Community <a href="about.php">About</a> <a href="faq.php">FAQ</a> <a href="user_login.php">LOGIN</a> <span class="orangefont">My CART</span> My Store Welcome: <?php echo $_SESSION['username'] ?></div> <div class="storeeditleftsidebar"><br /> <br /> <span class="storeheaderfont">Your Products</span><br /> <br /> <?php echo $display_block = "<a href=\"add_new_product.php?username=".$_SESSION['username']."\">Add New</a>" ?><br /> <?php echo $display_block = "<a href=\"current_products.php?username=".$_SESSION['username']."\">Current</a>" ?><br /> <?php echo $display_block = "<a href=\"sold_products.php?username=".$_SESSION['username']."\">Sold</a>" ?><br /> <br /> <span class="storeheaderfont">Your Store</span><br /><br /> <?php echo $display_block = "<a href=\"edit_artist_profile.php?username=".$_SESSION['username']."\">Your Artist Profile</a>" ?><br /> <?php echo $display_block = "<a href=\"edit_store_profile.php?username=".$_SESSION['username']."\">Your Store Profile</a>" ?><br /> <?php echo $display_block = "<a href=\"edit_store_policies.php?username=".$_SESSION['username']."\">Your Store Policies</a>" ?><br /> <br /> <?php echo $display_block = "<a href=\"edit_artist_account.php?username=".$_SESSION['username']."\">Account Information</a>" ?><br /> <?php echo $display_block = "<a href=\"_bill.php?username=".$_SESSION['username']."\">Your Bill</a>" ?><br /> <br /> <a href="seller_faqs.php">Seller FAQ's</a><br /> </div> <br /> <div class="storeeditright"> <br /> <span class="titlefont">Add a new product to your store</span><br /> <br /> <br /> <span class="itemmenufont">1. Add Item Information</span> 2. Confirm Item Info <span class="itemmenufont">3. Add Image</span> <span class="itemmenufont">4. Finalize Listing</span><br /> <br /> <br /> <span class="titles">Title:</span> <?php echo "$item_title" ?><br /> <br /> <span class="titles">Item Description:</span> <?php echo "$item_description" ?><br /> <br /> <span class="titles">Price:</span> <?php echo "$item_price" ?><br /> <br /> <span class="titles">Shipping From:</span> <?php echo "$item_location" ?><br /> <br /> <span class="titles">Ship To:</span> <?php echo "$item_ship_to" ?><br /> <br /> <span class="titles">Shipping Cost:</span> <?php echo "$item_shipping_cost" ?><br /> <br /> <span class="titles">Ship Internationally?:</span> <?php echo "$item_international" ?><br /> <br /> <span class="titles">International Shipping Cost:</span> <?php echo "$item_in_shipping" ?><br /> <br /> <br /><?php echo "$item_id" ?><br /> <span class="storeheaderfont">Edit your information here</span> <br /> <br /> Edit your information here.</span><br /><br /> <br /> <form action="update_new.php" method="post" enctype="multipart/form-data" name="update_new" id="update_new"> <span class="titles">Title:</span> <input type="text" name="title" size="40" value="<?php echo $item_title ?>" /><br /> <br /> <span class="titles">Item Description:</span> <br /> <p> <textarea name="description" rows=10 cols=60><?php echo $item_description ?></textarea></p><br /> <table width="542" height="225" border="0"> <tr> <td width="251" height="13" valign="bottom"><span class="titles">Price: </span>(US Dollars)</td> <td width="281" height="13" align="right" valign="bottom">$<input type="text" name="price" size="40" value="<?php echo $item_price ?>"?>"/></td> </tr> <tr> <td height="13" valign="bottom" class="titles">Shipping from:</td> <td height="13" align="right" valign="bottom"><input type="text" name="location" size="40" value="<?php echo $item_location ?>"/></td> </tr> <tr> <td height="13" valign="bottom" class="titles">Ship to:</td> <td height="13" align="right" valign="bottom"><input type="text" name="ship_to" size="40" value="<?php echo $item_ship_to ?>"/></td> </tr> <tr> <td height="13" valign="bottom" class="titles">Shipping Cost:</td> <td height="13" align="right" valign="bottom">$<input type="text" name="shipping_cost" size="40" value="<?php echo $item_shipping_cost ?>"/></td> </tr> <tr> <td height="13" valign="bottom" class="titles">Ship Internationally?:</td> <td height="13" valign="bottom"> <input type="radio" name="international" value="yes" />yes <input type="radio" name="international" value="no" />no </td> </tr> <tr> <td height="10" valign="bottom" class="titles">International Shipping Cost:</td> <td height="13" align="right" valign="bottom">$<input type="text" name="in_shipping" size="40" value="<?php echo $item_international ?>"/></td> </tr> </table> <br /><input name="id" type="hidden" id="id" value="<?php echo $item_id ?>" /> <br /> <input type="submit" name="submit" value="UPDATE" /> </form> <br /><br /> <br /> <?php echo $display_block = "<a href=\"add_new_product4.php?id={$item_id}username=".$_SESSION['username']."\">Add New Image</a>" ?></div> <div class="footergallery"><br /> <br /> Contact About Terms of Use Privacy Policy Copyright Policy </div> </div> </body></div> </html> Here is the php form action code: <?php session_start ()?> <?php mysql_connect("localhost", "", "", "store") or die(mysql_error()); mysql_select_db("store") or die(mysql_error()); $item_title = mysql_real_escape_string($_POST[title]); $item_description = mysql_real_escape_string($_POST[description]); $item_price = mysql_real_escape_string($_POST[price]); $item_location = mysql_real_escape_string($_POST[location]); $item_ship_to = mysql_real_escape_string($_POST[ship_to]); $item_shipping_cost = mysql_real_escape_string($_POST[shipping_cost]); $item_international = mysql_real_escape_string($_POST[international]); $item_in_shipping = mysql_real_escape_string($_POST[in_shipping]); $item_id = mysql_real_escape_string($_POST[id]); $username = $_SESSION['username']; $sql="UPDATE product SET title='$item_title', description='$item_description', price='$item_price', location='$item_location', ship_to='$item_ship_to', shipping_cost='$item_shipping_cost', international='$item_international', in_shipping='$item_in_shipping' WHERE id = $item_id"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); }else { header("location:add_new_product3.php?id={$item_id}"); } ?>
-
Yes, there is a form page just previous to that. Here is what I have: 1st the user goes to add a new item by giving a description. They click next. When this happens, it adds the new item, giving them a new product ID. Then it brings them to the next page where they can review the information they just put in and edit it if necessary. When finished they click next to go to where they add the image of their product. This is where I'm at. For some reason the ID isn't carrying over completely. Just for testing, I tried inputted the username into the update and of course it worked but updated ALL my image titles to that name. Now...to narrow it down to the product ID....
-
I just ran it again and after the image is uploaded, this is what is in the URL: http://localhost/add_new_product4.php?id=0=success&show_image=resized_June_2010_020.jpg See how the ID equals zero?
-
This code has all the inbetween stuff: <?php session_start (); ?> <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php mysql_connect("localhost", "", "", "store") or die(mysql_error()); mysql_select_db("store") or die(mysql_error()); $item_image = $_FILES['image_upload_box']['name']; $item_id = (int) ($_GET[id]); $sql="UPDATE product SET image_upload_box='$item_image' WHERE id = '$item_id'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/x-png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { // some settings $max_upload_width = 500; $max_upload_height = 500; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/x-png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } $remote_file = "image_files/".$_FILES["image_upload_box"]["name"]; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); header("Location: add_new_product4.php?id={$item_id}=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } else{ header("Location: add_new_product.php4?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } } ?> Here is the form code: <form action="submit.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <br /><label></label><br /> <input name="image_upload_box" type="file" id="image_upload_box" size="40" /> <input type="submit" name="submit" value="Upload image" /> <br /><br /> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /> </form> Thanks for your help!
-
Here is the revised code: (thanks!) <?php session_start (); ?> <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php mysql_connect("localhost", "", "", "store") or die(mysql_error()); mysql_select_db("store") or die(mysql_error()); $item_image = $_FILES['image_upload_box']['name']; $item_id = (int) ($_GET[id]); $sql="UPDATE product SET image_upload_box='$item_image' WHERE id = '$item_id'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { header("Location: add_new_product4.php?id={$item_id}=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } else{ header("Location: add_new_product.php4?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; }
-
Okay...I updated that but the correct ID still isn't passing through. It's showing up as "0". Hmmm. So I plugged in your previous code to see what it was doing. Here is what it says: UPDATE product SET image_upload_box='resized_June_2010_015.jpg' WHERE id = '0' Now...before I click this update button to upload and update the image, this is what it says in the URL: http://localhost/add_new_product4.php?id=65 It says the correct ID number. Any suggestions?
-
Okay...Pikachu2000, after inputting what you suggested, this is what came up in the browser: Array ( [image_upload_box] => Array ( [name] => resized_June_2010_007.jpg [type] => image/jpeg [tmp_name] => C:\Users\Desktop\xampp\tmp\php3295.tmp [error] => 0 [size] => 54351 ) ) UPDATE product SET image_upload_box='resized_June_2010_007.jpg' WHERE id = '' What do you make of that? It looks as though my id is not carrying over, although its up in the URL. ???
-
(I've shortened the code a bit for viewing) Okay, I got the other part I posted previously working. Now once the user is satisfied with addind/updating their details they move on to a new page where they will upload an image. I'm able to upload the image just fine but I'm trying to get the file name of the image to be inserted into the associated product record in the table. When I click it, it returns my image to the browser (good) and uploads it (good) but does not put the name in the product record. Here is the form action code for this page: <?php session_start (); ?> <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php mysql_connect("localhost", "root", "", "sgallery") or die(mysql_error()); mysql_select_db("sgallery") or die(mysql_error()); $item_image = $_FILES['image_upload_box']['name']; $item_id = mysql_real_escape_string($_POST[id]); $sql="UPDATE product SET image_upload_box='$item_image' WHERE id = '$item_id'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { header("Location: add_new_product4.php?id={$item_id}=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } else{ header("Location: add_new_product.php4?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } } ?> It's also not holding the $item_id in the URL code from above: header("Location: add_new_product4.php?id={$item_id}=success&show_image=".$_FILES["image_upload_box"]["name"]);