blueovaltv Posted October 16, 2007 Share Posted October 16, 2007 I have http://FLcarsForYou.com almost working... except I cant get the images to sort correctly. On the admin upload area, ive asked the customer to add the "main listing" picture first, so it does not come up with a picture of the interior on the multi-listing pages. I must have screwed something up, because now it lists the last picture as the main image... So.. if you are the know-all of sorting... please give me guidance. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/ Share on other sites More sharing options...
Barand Posted October 16, 2007 Share Posted October 16, 2007 Do you have the date/time of upload stored in the image table with the images? Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-370994 Share on other sites More sharing options...
blueovaltv Posted October 16, 2007 Author Share Posted October 16, 2007 Ill need to look, its pieced together from scripts i found online Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-370996 Share on other sites More sharing options...
blueovaltv Posted October 16, 2007 Author Share Posted October 16, 2007 The table has id_files which is an incremental rising number per upload... and it looks like the uploaded files keep the its filename used by his digital camera "DSCF9816.JPG" which makes me think they are being listed by alphabetical right now, because some will work for him and others wont. Feel like im getting closer, but no, there is no timestamp column Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-371000 Share on other sites More sharing options...
Barand Posted October 16, 2007 Share Posted October 16, 2007 So what code do have now to retrieve and display the images Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-371004 Share on other sites More sharing options...
blueovaltv Posted October 16, 2007 Author Share Posted October 16, 2007 //select images connected to a given listing $query = "SELECT * FROM tbl_Files WHERE prop_num = $a_row[id] LIMIT 1"; $output = mysql_query("$query",$link); $count = 0; while ($image_row =mysql_fetch_array ($output) ) { print "<td valign=top align=center width=115><a href=\"./carview.php?view=$a_row[id]\"><img src='image.php?Id=$image_row[id_files]' border=1 width=175 alt=\"Photo\"></a><br></td>"; $count++; } if ($count == 0) { print "<td valign=top align=center width=115><a href=\"./carview.php?view=$a_row[id]\"><img src=\"./images/nophoto.gif\" border=1 width=175 alt=\"View Listing\"></a><br></td>"; } That should be the multi-listing portion... and the individual listing page //select images connected to a given listing $count = 0; $query = "SELECT * FROM tbl_Files WHERE prop_num = $a_row[id]"; $result = mysql_query("$query",$link); while ($image_row =mysql_fetch_array ($result) ) { print "<font face=\"arial\" size=1><b>Click photos to enlarge</b></font><br><br><p>"; echo "<B>"; echo stripslashes($image_row[description]) . "<BR>\n"; echo "</b><table border=1 cellspacing=0 cellpadding=0 width=100><tr><td align=center><a href=\"http://flcarsforyou.com/image.php?Id=$image_row[id_files]\" target=\"_new\"><img src='image.php?Id=$image_row[id_files]' border=0 width=175 alt='Click to Enlarge'></a></td></tr></table>"; echo "<P> \n"; $count++; } print "</font>"; if ($count == 0) { print "<table border=1 cellspacing=0 cellpadding=0 width=100><tr><td align=center><img src=\"./images/nophoto.gif\" border=0 width=175></a></td></tr></table>"; } elseif ($count == 1) { print "<font face=\"arial\" size=1><b>Click photo to enlarge</b></font><br><br><p>"; } else { print "<font face=\"arial\" size=1><b>Click photos to enlarge</b></font><br><br><p>"; } Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-371007 Share on other sites More sharing options...
blueovaltv Posted October 16, 2007 Author Share Posted October 16, 2007 And here is the upload part, incase i can update it to add timestamp.. Now that i think about it... Timestamp might be an issue if the customer wants to delete a picture and update it... it would then be the latest added.. if ($action == "upload") { if (isset($binFile) && $binFile != "none") { $data = addslashes(fread(fopen($binFile, "r"), filesize($binFile))); $strDescription = addslashes(nl2br($txtDescription)); $sql = "INSERT INTO tbl_Files "; $sql .= "(description, bin_data, filename, filesize, filetype, owner, prop_num) "; $sql .= "VALUES ('$strDescription', '$data', "; $sql .= "'$binFile_name', '$binFile_size', '$binFile_type', '$current_user', '$propnum')"; if (!mysql_query ($sql, $link) ) { die (mysql_error()); } echo "Your image has been added ($binFile_name)."; } } Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-371013 Share on other sites More sharing options...
blueovaltv Posted October 16, 2007 Author Share Posted October 16, 2007 Maybe adding a checkbox next to the images in the admin section, allowing the customer to upload all images, and then select the main image... Im guessing that would need a checkbox with a value of 1 or 0 and then make the images list with "is_main_image=1" coming up first. Does that make much sence? I havent had much php experience.. especiall with mysql Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-371031 Share on other sites More sharing options...
Barand Posted October 16, 2007 Share Posted October 16, 2007 Getting the user to specify the main image seems the best idea, rather than relying on the order. I'd use radio buttons rather that checkboxes to make sure only one can be specified, Quote Link to comment https://forums.phpfreaks.com/topic/73531-need-help-with-sorting-images-from-a-db-by-order-of-upload-thanks/#findComment-371059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.