Jump to content

scmeeker

Members
  • Posts

    153
  • Joined

  • Last visited

    Never

Everything posted by scmeeker

  1. I think I'm missing part of your response. I did put in another " at the end but it's giving me an error.
  2. I have gone over this and over it and I can't find the syntax error. Perhaps another set of eyes will find it. $sql="UPDATE product SET title='$item_title', description='$item_description', price='$item_price', ship_to='$item_ship_to', shipping_cost='$item_shipping_cost', international='$item_international', in_location='$item_in_location', in_shipping='$item_in_shipping', country='$item_country', city='$item_city', state='$item_state', sub_id='$item_sub_id', cat_id='$item_cat_id', date=NOW(), exp_date=DATE_ADD(NOW()INTERVAL 59 DAY), relist_date=DATE_ADD(NOW(),INTERVAL 45 DAY), image_upload_box='$item_image_upload', thumb='$item_thumb', artist_email='$artist_email' WHERE id = '"$_GET['id']'";
  3. I did put the HTML links in the page but it still not working and showing the same output of "Sorry, no items in this category." I noticed that your ORDER BY was blank after it. Was that intentional? Thanks for your help.
  4. I tried this but now nothing from my database is showing up. It says "Sorry, no items in this category." From this line of code: if (mysql_num_rows($get_items_sql) < 1) { $content = "<p><em>Sorry, no items in this category.</em></p>\n"; }
  5. I'm trying to figure out a way to incorporate multiple sorts on my php page. On the page of products, I want users to have three choices of links: one by date, one by price - low to high and one by price - high to low. I know how to perform ASC & DESC sorts in MySql but I'm not sure how to go about this sort with the three choices without creating more pages. I would really like it to stay with the same page. Is this even possible?? How would I go about it? Here is the section of code : $get_items_sql = mysql_query("SELECT id, thumb, username, sub_id, title, ROUND(price,2) AS price, date FROM product WHERE CURDATE() <= relist_date AND inactive IS NULL AND sold IS NULL AND cat_id = '1' ORDER BY date ") or die(mysql_error());; if (mysql_num_rows($get_items_sql) < 1) { $content = "<p><em>Sorry, no items in this category.</em></p>\n"; } else { $col = 0; $content .= "<ul>\n"; while ($items = mysql_fetch_array($get_items_sql)) { $item_url = "items3.php?id={$items['id']}&username={$items['username']}"; $item_title = stripslashes($items['title']); $item_price = $items['price']; $item_photo = $items['thumb']; $item_username = $items['username']; $item_date = $items['date']; $content .= ""; list($width) = getimagesize("image_files/{$item_photo}"); // set the maximum width of the image here $maxWidth = 100; if ($width > $maxWidth); $content .= "<table width=\"693\" border=\"0\" class=anotherfont><tr><td width=\"101\"> <a href=\"{$item_url}\"> <img alt=\"{$item_title}\" border=0 width=\"{$maxWidth}\" src=\"image_files/{$item_photo}\" /></a><td width=\"200\"> <a href=\"{$item_url}\">{$item_title}</a></td> <td width=\"109\">{$item_username}</td><td width=\"101\"> {$item_date}</td><td width=\"99\">\${$item_price} USD </td></tr></table>"; $content .= "\n";
  6. Thank you SO much! It works great now and I've been struggling with it. I REALLY appreciate your help.
  7. Thanks! It's working fine now but I was wondering if there was a way to limit the number shown per row? It doesn't want to stay within my css box.
  8. I tried inserting this code like you suggested but the images still stack, although the title is below it now.
  9. It still doesn't work. And the reason I left the beginning of the table tag is so that the images would be shown in a row next to each other, rather than stacked. The titles are still showing up next the image rather than below it. Any other suggestions? Thanks.
  10. Sorry, here is the code: //validate item $get_item_sql = mysql_query("SELECT s.item_id, s.artist, p.id, p.thumb, p.username, p.title, p.name FROM product AS p LEFT JOIN picks AS s on s.item_id = p.id WHERE s.date = CURDATE()") or die(mysql_error()); if (mysql_num_rows($get_item_sql) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_info = mysql_fetch_array($get_item_sql)) { $item_id = $item_info['item_id']; $item_artist = $item_info['artist']; $item_photo = $item_info['thumb']; $item_username = $item_info['username']; $item_title = $item_info['title']; $item_name = $item_info['name']; $image_row .= "<tr height=\"200\">"; $image_row .= "<td ><img src=\"image_files/{$item_photo}\" alt=\"{$item_name}\" /><br /> {$item_title} </td>"; $image_row .= "</tr> </table>"; } }
  11. I tried this but its still not working properly: $image_row .= "<tr height=\"200\">"; $image_row .= "<td ><img src=\"image_files/{$item_photo}\" alt=\"{$item_name}\" /><br /> {$item_title} </td>"; $image_row .= "</tr> </table>";
  12. I'm displaying a row of images but I can't seem to get the title to stay under the image. When I try to insert a <br> or <br /> the the $item_title, it changes the whole dynamics of the row, placing the $item_title next to the image rather than under it. Here is the code: $image_row .= "<tr height=\"200\"><td ><img src=\"image_files/{$item_photo}\" alt=\"{$item_name}\" /><br />{$item_title} </td></tr> </table>";
  13. Thanks SO much for your help! It works perfect now. It's truly all the little things.
  14. I'm having a problem with getting the timestamp to attach to the filename. Currently when it's uploaded in the database it says $timestamp in front of the filename instead of the time. Scroll down towards the bottom of the code to see it. Thanks for your help! $username = $_GET['username']; $item_id = $_GET['id']; define( 'DESIRED_IMAGE_WIDTH', 150 ); define( 'DESIRED_IMAGE_HEIGHT', 150 ); $source_path = $_FILES[ 'thumb' ][ 'tmp_name' ]; $timestamp = time(); // // Add file validation code here // list( $source_width, $source_height, $source_type ) = getimagesize( $source_path ); switch ( $source_type ) { case IMAGETYPE_GIF: $source_gdim = imagecreatefromgif( $source_path ); break; case IMAGETYPE_JPEG: $source_gdim = imagecreatefromjpeg( $source_path ); break; case IMAGETYPE_PNG: $source_gdim = imagecreatefrompng( $source_path ); break; } $source_aspect_ratio = $source_width / $source_height; $desired_aspect_ratio = DESIRED_IMAGE_WIDTH / DESIRED_IMAGE_HEIGHT; if ( $source_aspect_ratio > $desired_aspect_ratio ) { // // Triggered when source image is wider // $temp_height = DESIRED_IMAGE_HEIGHT; $temp_width = ( int ) ( DESIRED_IMAGE_HEIGHT * $source_aspect_ratio ); } else { // // Triggered otherwise (i.e. source image is similar or taller) // $temp_width = DESIRED_IMAGE_WIDTH; $temp_height = ( int ) ( DESIRED_IMAGE_WIDTH / $source_aspect_ratio ); } // // Resize the image into a temporary GD image // $temp_gdim = imagecreatetruecolor( $temp_width, $temp_height ); imagecopyresampled( $temp_gdim, $source_gdim, 0, 0, 0, 0, $temp_width, $temp_height, $source_width, $source_height ); // // Copy cropped region from temporary image into the desired GD image // $x0 = ( $temp_width - DESIRED_IMAGE_WIDTH ) / 2; $y0 = ( $temp_height - DESIRED_IMAGE_HEIGHT ) / 2; $desired_gdim = imagecreatetruecolor( DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT ); imagecopy( $desired_gdim, $temp_gdim, 0, 0, $x0, $y0, DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT ); // // Render the image // Alternatively, you can save the image in file-system or database // header( 'Content-type: image/jpeg' ); imagejpeg( $desired_gdim, "image_files/".'$timestamp'.$_FILES["thumb"]["name"] ); mysql_connect("localhost", "root", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); $timestamp = time(); $item_image = '"$timestamp"'.$_FILES['thumb']['name']; $sql="UPDATE product SET thumb='$item_image' WHERE id = '$item_id'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error());
  15. I have a series of steps a user goes through to add a product. I'm having a problem with the first going to second page. The first page is a form to input information which has a "add" php file that goes with it that basically Posts and Inserts the information into the table, then moves on to the next page. It also auto increments a new id for the product in the table during this process. The problem is I'm trying to get the product id to carry over to the next page so they can review the information they just input. Any ideas on how I can pull that new id by going from that one page to the next with that move (Form>Insert(form action)>EditPage)? I'm just having a hard time visualizing this because I'm inserting the new product then there's nothing to reference because I can't pinpoint on the id yet.
  16. I made the change but the image is still showing up as a black square and now at least its down to one warning: Warning: imagejpeg() [function.imagejpeg]: Unable to open 'image_files/C:\Desktop\xampp\tmp\php659A.tmp' for writing: Invalid argument in C:\Users\Samantha\Desktop\xampp\htdocs\image-crop-demo.php on line 109 The problem also is that its changing the file name to a temporary file in the database. Any other suggestions? I appreciate your help.
  17. I'm able to get the image file name in the database, the image to the right place BUT the problem is the image is totally black and after it's uploaded, a whole bunch of warnings appear. Here are the warnings: Warning: getimagesize(image_files/image-16.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 37 Warning: Division by zero in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 54 Warning: Division by zero in C:\Users\Samantha\Desktop\xampp\htdocs\image-crop-demo.php on line 71 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 78 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 86 Warning: imagecopy() expects parameter 2 to be resource, boolean given in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 102 Here is the form: <form action="image-crop-demo.php?username=<?php echo $username ?>" method="post" enctype="multipart/form-data"> Upload an image for processing<br> <input type="file" name="Image1"><br> <input type="submit" value="Upload"> </form> And here is the form action file: $username = $_GET['username']; define( 'DESIRED_IMAGE_WIDTH', 150 ); define( 'DESIRED_IMAGE_HEIGHT', 150 ); $source_path = $_FILES[ 'Image1' ][ 'name' ]; $sql="UPDATE thumbnail SET Image1='$source_path' WHERE username = '$username'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { // // Add file validation code here // list( $source_width, $source_height, $source_type ) = getimagesize( $source_path ); switch ( $source_type ) { case IMAGETYPE_GIF: $source_gdim = imagecreatefromgif( $source_path ); break; case IMAGETYPE_JPEG: $source_gdim = imagecreatefromjpeg( $source_path ); break; case IMAGETYPE_PNG: $source_gdim = imagecreatefrompng( $source_path ); break; } $source_aspect_ratio = $source_width / $source_height; $desired_aspect_ratio = DESIRED_IMAGE_WIDTH / DESIRED_IMAGE_HEIGHT; if ( $source_aspect_ratio > $desired_aspect_ratio ) { // // Triggered when source image is wider // $temp_height = DESIRED_IMAGE_HEIGHT; $temp_width = ( int ) ( DESIRED_IMAGE_HEIGHT * $source_aspect_ratio ); } else { // // Triggered otherwise (i.e. source image is similar or taller) // $temp_width = DESIRED_IMAGE_WIDTH; $temp_height = ( int ) ( DESIRED_IMAGE_WIDTH / $source_aspect_ratio ); } // // Resize the image into a temporary GD image // $temp_gdim = imagecreatetruecolor( $temp_width, $temp_height ); imagecopyresampled( $temp_gdim, $source_gdim, 0, 0, 0, 0, $temp_width, $temp_height, $source_width, $source_height ); // // Copy cropped region from temporary image into the desired GD image // $x0 = ( $temp_width - DESIRED_IMAGE_WIDTH ) / 2; $y0 = ( $temp_height - DESIRED_IMAGE_HEIGHT ) / 2; $desired_gdim = imagecreatetruecolor( DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT ); imagecopy( $desired_gdim, $temp_gdim, 0, 0, $x0, $y0, DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT ); // // Render the image // Alternatively, you can save the image in file-system or database $remote_file = "image_files/".$_FILES["Image1"]["name"]; imagejpeg($desired_gdim,$remote_file); }//
  18. Okay...got it to work. I didn't remove the GROUP BY at the end of the second query like you said. Sorry! Thank you for your help!
  19. When I made that change, it only would list one user and their information, not every user.
  20. I'm trying to create a list that groups information by username. Only part of it is working. The first query ($get_item_sql) is grouping the information perfectly but the second query ($get_sold) is lumping the $item_price and $item_amount_due as one total for each one and outputting the same amounts into every username. I'm stuck on this and would appreciate your help. For example: Username item fees image fees item sales item price total due Jim 2 $0.40 $100.00 $3.00 $3.40 Kelly 5 $1.00 $100.00 $3.00 $4.00 This example shows the columns in red as being the problem where Kelly didn't sell anything so her "item sales" and "item price" should be $0.00 but is carrying Jim's totals into hers. Hope this helps! Thank you! $get_item_sql = mysql_query("SELECT id, username, date, ROUND(price,2) AS price, SUM(item_fee) AS fee, item_fee, SUM(sold) AS sales, SUM(ROUND(price,2)) AS total FROM product WHERE MONTH(date) = MONTH(DATE_ADD(CURDATE(),INTERVAL -1 MONTH)) GROUP BY username" ) or die(mysql_error()); if (mysql_num_rows($get_item_sql) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_info = mysql_fetch_array($get_item_sql)) { $item_username = $item_info['username']; $item_date = $item_info['date']; $item_price = $item_info['price']; $item_fee = $item_info['fee']; $image_fees = $item_fee * .20; $item_sold = $item_info['sales']; $get_sold = mysql_query("SELECT SUM(ROUND(price,2)) AS total, SUM(ROUND(sold,2)) AS sales, date, username FROM product WHERE sold = '1' AND MONTH(date) = MONTH(DATE_ADD(CURDATE(),INTERVAL -1 MONTH)) GROUP BY username") or die(mysql_error()); if (mysql_num_rows($get_sold) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_sold2 = mysql_fetch_array($get_sold)) { $item_sales = $item_sold2['total']; $item_price = ($item_sold2['total']) * .03; $item_amount_due = $image_fees + $item_price; $content .= "<form action=\"add_artist.php\" method=\"post\"><table class=\"anotherfont\" width=\"670\" border=\"0\"> <tr><td width=\"201\">{$item_username}</td> <td width=\"109\">{$item_fee}</td> <td width=\"109\">{$image_fees}</td> <td width=\"109\"> {$item_sales}</td> <td width=\"109\"> {$item_price}</td> <td width=\"109\"><input name=\"balance_due\" type=\"text\" value=\"{$item_amount_due}\" /></td> </tr><br /></table></form>"; } } } }
  21. I changed the transaction_id "type" in mysql to Varchar and its working fine now. Hours gone...how frustrating. Thanks you for your help, it pushed me in the right direction.
  22. The number that keeps getting inserted into the transaction_id column is "2147483647" and this is the structure of that column: transaction_id int(200) The numbers that keep going into the URL are at this length: 6179917971979951556
  23. As far as the structure of the buyers table, all the columns are listed in the Insert ($sql) that is listed except the id that is auto-incremented. The transaction_id is an integer. Again, I'm not sure what your asking?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.