$php_mysql$ Posted September 18, 2010 Share Posted September 18, 2010 could someone be kind to help add a image upload field in the form? below my source ///////////////////////////////////////auto delete ads $time_count = 7*24*60*60; // count the 7 days Ads will be deleted $match_time = time()-$time_count; $query = "SELECT id FROM classifieds WHERE time<'".$match_time."' ORDER BY RAND() LIMIT 1"; $result = mysql_query($query); while($ad_id = mysql_fetch_array($result)) $delete =$ad_id[0]; mysql_query("DELETE FROM classifieds WHERE id='$delete'"); ////////////////////////////////////////MAIN PAGE if($action=="main") { $result=mysql_query("select * from classifieds where cat='career_jobs'"); $career_jobs = mysql_num_rows($result); $result=mysql_query("select * from classifieds where cat='realestate'"); $realestate = mysql_num_rows($result); $result=mysql_query("select * from classifieds where cat='vehicles'"); $vehicles = mysql_num_rows($result); $result=mysql_query("select * from classifieds where cat='buy_sell'"); $buy_sell = mysql_num_rows($result); $result=mysql_query("select * from classifieds where cat='services'"); $services = mysql_num_rows($result); $result=mysql_query("select * from classifieds where cat='pets'"); $pets = mysql_num_rows($result); $result=mysql_query("select * from classifieds where cat='events_announcements'"); $events_announcements = mysql_num_rows($result); echo "<center><br/><big>Wapvibes Classifieds</big><br/><br/></center>"; echo "<big><u><b>Classifieds</b></u></p>"; echo "<p>»<a href=\"classifieds.php?action=show_ads&sid=$sid&cat=career_jobs\">Career/Jobs</a>($career_jobs)<br/>"; echo "»<a href=\"classifieds.php?action=show_ads&sid=$sid&cat=realestate\">Real Estate</a>($realestate)<br/>"; echo "»<a title=\"Enter\" href=\"classifieds.php?action=show_ads&sid=$sid&cat=vehicles\">Vehicles</a>($vehicles)<br/>"; echo "»<a title=\"Enter\" href=\"classifieds.php?action=show_ads&sid=$sid&cat=buy_sell\">Buy/Sell</a>($buy_sell)<br/>"; echo "»<a title=\"Enter\" href=\"classifieds.php?action=show_ads&sid=$sid&cat=services\">Services</a>($services)<br/>"; echo "»<a title=\"Enter\" href=\"classifieds.php?action=show_ads&sid=$sid&cat=pets\">Pets</a>($pets)<br/>"; echo "»<a title=\"Enter\" href=\"classifieds.php?action=show_ads&sid=$sid&cat=events_announcements\">Events/Announcements</a>($events_announcements)<br/>"; echo "<br/><a title=\"Enter\" href=\"classifieds.php?action=post&sid=$sid\">Post Your Ads</a>"; } ////////////////////////////////////////////////// else if($action=="show_ads") { echo "<h3 align=\"center\">Classifieds</h3>\n"; $cat=$_GET["cat"]; $page=$_GET["page"]; if($page=="") { $page=1; } $max_results = 7; $from = (($page * $max_results) - $max_results); $total_results = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM classifieds WHERE cat='$cat'")); if($total_results[0]<1) { echo "<p>Sorry No Ads to show yet!!!</p><br/>"; }else{ $total_pages = ceil($total_results[0] / $max_results); echo "$page Of $total_pages<br/><br/>"; $sql = mysql_query("SELECT * FROM classifieds WHERE cat='$cat' ORDER BY id desc LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){ $name = $row['uid']; $name2 = $row['itemname']; $key = $row['id']; echo "<a href=\"classifieds.php?action=details&sid=$sid&cat=$cat&key=$key\">$name2</a><br/>" ; } if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"classifieds.php?action=show_ads&sid=$sid&page=$next&cat=$cat\">Next</a><br />"; } if($page > 1){ $prev = ($page - 1); echo "<a href=\"classifieds.php?action=show_ads&sid=$sid&page=$prev&cat=$cat\">Prev</a><br/>"; } $i = 1; $i <= $total_pages; $i++ ; } echo "<p align=\"center\">"; echo "<h3 align=\"center\"><a href=\"index.php?action=main&sid=$sid\">Home</a></h3>\n"; echo "</p>"; echo "</body>"; } /////////////////////////////////////////////////// else if($action=="details") { echo "<h3 align=\"center\">Ad Details</h3>\n"; $key=$_GET["key"]; $cat=$_GET["cat"]; $sql = mysql_fetch_array(mysql_query("SELECT * FROM classifieds WHERE id='$key'")); $usid=$sql["uid"]; $who=$usid; $name=getnick_uid($usid); $ad=$sql["ad"]; $price=$sql["price"]; $contact=$sql["contact"]; $location=$sql["location"]; $posted=$sql["time"]; $wapvibes_ad_time = date("d/m/Y h:i:s A", $posted); echo "<br/>"; echo "<p>"; echo "<big><b>*Seller</b><br/> <a href=\"index.php?action=viewuser&sid=$sid&who=$usid\">$name</a><br/><br/>"; echo "<b>*Description*</b><br/> $ad<br/><br/>"; echo "<b>*Price*</b><br/> $price<br/>"; echo "<b>*Contact*</b><br/> $contact<br/><br/>"; echo "<b>*Location*</b><br/> $location<br/>"; echo "<b>*Posted on</b><br/> $wapvibes_ad_time<br/>"; echo "<br/>"; echo "<a href=\"inbox.php?action=sendpm&who=$usid&sid=$sid\">[send $name A PM]</a><br/><br/>"; if (isowner($uid)){ echo "<p><a href=\"classifieds.php?action=delete44&who=$who&sid=$sid\">Delete This Ad</a></p>"; } echo "<a href=\"classifieds.php?action=show_ads&sid=$sid&cat=$cat\">Back to Category</a>"; echo "<p align=\"center\">"; echo "<h3 align=\"center\"><a href=\"index.php?action=main&sid=$sid\">Home</a></h3>\n"; echo "</p>"; echo "</body>"; } //////////////////////////////////////////////////// else if($action=="post") { echo "<h3 align=\"center\">Post An Advertisement</h3>\n"; echo "<form action=\"classifieds.php?action=post2&sid=$sid\" method=\"post\">"; echo "<p>"; echo "What is the Name of Your Item<br/>"; echo "<br/>"; echo "<textarea class=\"inputText\" name=\"name\"></textarea><br/>"; echo "Describe Your Item<br/>"; echo "<br/>"; echo "<textarea class=\"inputText\" name=\"ad\"></textarea><br/>"; echo "Choose Category"; echo "<br/><select name=\"listing\">"; echo "<option value=\"select\">select</option>"; echo "<option value=\"career_jobs\">Career/Jobs</option>"; echo "<option value=\"realestate\">Real Estate</option>"; echo "<option value=\"vehicles\">Vehicles</option>"; echo "<option value=\"buy_sell\">Buy/Sell</option>"; echo "<option value=\"services\">Services</option>"; echo "<option value=\"pets\">Pets</option>"; echo "<option value=\"events_announcements\">Events/Announcements</option>"; echo "</select><br/>"; echo "what is Your Price<br/>"; echo "<textarea class=\"inputText\" name=\"price\"></textarea><br/>"; echo "How can You be contacted:"; echo "<br/><textarea class=\"inputText\" name=\"contact\"></textarea><br/>"; echo "Where Are You Located"; echo "<br/><textarea class=\"inputText\" name=\"location\"></textarea><br/>"; $ui=getuid_sid($sid); echo "<input type=\"hidden\" name=\"ui\" value=\"$ui\"/>"; echo "<br/><input name=\"submit\" value=\"Submit Your Ad\" type=\"submit\"/><br/></p></form><p>"; echo "<p align=\"center\">"; echo "<h3 align=\"center\"><a href=\"index.php?action=main&sid=$sid\">Home</a></h3>\n"; echo "</p>"; echo "</body>"; } /////////////////////////////////////////////////////// else if($action=="delete44") { echo "<h3 align=\"center\">Ad Deleted</h3>\n"; echo "<p>"; echo "<big>Ad was successfully Deleted From the system</p>"; mysql_query("DELETE FROM classifieds WHERE uid='".$who."'"); echo "<p align=\"center\">"; echo "<h3 align=\"center\"><a href=\"index.php?action=main&sid=$sid\">Home</a></h3>\n"; echo "</p>"; echo "</body>"; } ///////////////////////////////////////////////////////////////// else if($action=="post2") { $name=$_POST["name"]; $ad=$_POST["ad"]; $price=$_POST["price"]; $contact=$_POST["contact"]; $cat=$_POST["listing"]; $location=$_POST["location"]; $ui=$_POST["ui"]; if(empty($name) || empty($ad) || empty($price) || empty($contact) || empty($location)) { echo "<h3 align=\"center\">Error!</h3>\n"; echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>"; echo "All fields are must<br/>"; die ("SmS Not Sent! <br/><br/><a href=\"classifieds.php?action=post&sid=$sid\">Return Back</a><br/> <h3 align=\"center\"><a href=\"index.php?action=main&sid=$sid\">Home</a></h3>\n"); } $result=mysql_query("select * from classifieds where uid='$ui' and cat='$cat'"); $number_of_rows = mysql_num_rows($result); if ($number_of_rows>0){ echo "<h3 align=\"center\">Error!</h3>\n"; $problems="1"; echo "<img src=\"images/notok.gif\" alt=\"x\"/> You already have a Ad in our system Please wait until your Ad expire in 7 days! <br/>"; } if ($problems==""){ echo "<h3 align=\"center\">Advertisement Added Successfully</h3>\n"; $sql = "INSERT INTO classifieds (uid, cat, ad, itemname, time, price,contact,location) VALUES ('$ui','$cat','$ad','$name','".time()."','$price','$contact','$location')"; $result = mysql_query($sql); echo "<img src=\"images/ok.gif\" alt=\"O\"/> Your Advertisement was Successfully Posted it will be in the Classified for 7 days, After that it will expire<br/><br/>"; echo "<br/><a href=\"classifieds.php?action=main&sid=$sid\">classified Main</a><br/>"; } echo "<p align=\"center\">"; echo "<h3 align=\"center\"><a href=\"index.php?action=main&sid=$sid\">Home</a></h3>\n"; echo "</p>"; echo "</body>"; and the sql CREATE TABLE IF NOT EXISTS `classifieds` ( `id` mediumint(4) NOT NULL auto_increment, `uid` varchar(20) NOT NULL default '', `cat` varchar(100) NOT NULL default '', `ad` text NOT NULL, `price` text NOT NULL, `time` int(100) NOT NULL, `contact` text NOT NULL, `itemname` text NOT NULL, `location` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=207 ; everything works fine just need to add a image upload along with form and also that it gets deleted from directory when posts auto deletes in 7 dyas. thanks Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/ Share on other sites More sharing options...
$php_mysql$ Posted September 18, 2010 Author Share Posted September 18, 2010 any one can help? Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1112573 Share on other sites More sharing options...
Mod-Jay Posted September 18, 2010 Share Posted September 18, 2010 Here at phpfreaks We Help you. We dont code every little thing for you. try looking up uploader on google and go from there, if you've got any problems you can post it on here. We'll Be glad to assist you. -Thank Mod-Jay Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1112625 Share on other sites More sharing options...
$php_mysql$ Posted September 19, 2010 Author Share Posted September 19, 2010 i have not done image upload so i do not understand well, can u atleast guide so that i can follow? Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1112715 Share on other sites More sharing options...
WatsonN Posted September 19, 2010 Share Posted September 19, 2010 Here is a good Tutorial http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1112836 Share on other sites More sharing options...
$php_mysql$ Posted September 21, 2010 Author Share Posted September 21, 2010 ok someone help me with this because i just not being able to, i give $2 for the help with paypal. Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1113625 Share on other sites More sharing options...
WatsonN Posted September 23, 2010 Share Posted September 23, 2010 Ok, then lets help you understand. . . Do you want the image to be uploaded into the same table or a separate one? Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1114364 Share on other sites More sharing options...
chintansshah Posted September 23, 2010 Share Posted September 23, 2010 Hey $php_mysql$, I want few inputs from you. 1. DB table with DATA 2. Fatal error: Call to undefined function getuid_sid(), so need function getuid_sid() Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1114376 Share on other sites More sharing options...
$php_mysql$ Posted September 28, 2010 Author Share Posted September 28, 2010 Hey $php_mysql$, I want few inputs from you. 1. DB table with DATA 2. Fatal error: Call to undefined function getuid_sid(), so need function getuid_sid() thanks mate for help but i managed to add it :-) Link to comment https://forums.phpfreaks.com/topic/213735-help-add-a-image-upload-field-in-form/#findComment-1116712 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.