jeger003 Posted December 28, 2008 Share Posted December 28, 2008 i have a classifieds site where my users can post ads and sell there stuff. what i am trying to do is list the users ads right after they log in....so that they can see what ads they have live and what are expired. So i would have it display specific to the user ID. Im not really sure where to start I was hoping some one can point me in the right direction and let me know what i should be looking for. i would appreciate any help Quote Link to comment Share on other sites More sharing options...
opalelement Posted December 28, 2008 Share Posted December 28, 2008 Are the classifieds saved in a MySQL database? Quote Link to comment Share on other sites More sharing options...
jeger003 Posted December 28, 2008 Author Share Posted December 28, 2008 yes, once a user registers they are assigned a "seller" number which is saved in mysql. below is a code i was able to put together to just list all the ads live but of course i cant have this display on users accounts cause it would be displaying all the users ads. seller field below would display the sellers #(user number) and then ad name next to it <? $data = mysql_query("SELECT * FROM ads_classifieds WHERE live='1' ORDER BY seller") or die(mysql_error()); Print "<table border cellpadding=3>"; Print "<br><b>Ads Live</b><br><br>"; Print "<td>". "Title</td> "; Print "<td>". "Seller</td>"; Print "<td>". "Views</td>"; Print "<td>"."Exp Notice</td></tr>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['title'] . "</td> "; Print "<td>".$info['seller'] . " </td>"; Print "<td>".$info['viewed'] . " </td>"; Print "<td>".$info['expiration_notice'] . " </td></tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
opalelement Posted December 28, 2008 Share Posted December 28, 2008 I'm not sure how you get the id of the current user who is viewing the page, but try it like this... (assume $current_viewing_user_id for the current viewing user's id, and `user_id` in the query is the database column of user ids) <? $data = mysql_query("SELECT * FROM ads_classifieds WHERE live='1' AND user_id=" . $current_viewing_user_id . " ORDER BY seller") or die(mysql_error()); Print "<table border cellpadding=3>"; Print "<br><b>Ads Live</b><br><br>"; Print "<td>". "Title</td> "; Print "<td>". "Seller</td>"; Print "<td>". "Views</td>"; Print "<td>"."Exp Notice</td></tr>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['title'] . "</td> "; Print "<td>".$info['seller'] . " </td>"; Print "<td>".$info['viewed'] . " </td>"; Print "<td>".$info['expiration_notice'] . " </td></tr>"; } ?> This query is like saying "Select the information from ads_classifieds where it is still active and the owner is the person looking at the page." Quote Link to comment Share on other sites More sharing options...
jeger003 Posted December 29, 2008 Author Share Posted December 29, 2008 im sorry im a little confused im not sure what $current_viewing_user_id does or what im supposed to do with but the query wont allow two " cause it cuts it off and when i use ' the $current_viewing_user_id doesnt work Quote Link to comment Share on other sites More sharing options...
opalelement Posted December 29, 2008 Share Posted December 29, 2008 When someone logs in, how do you confirm that they are logged on? Do you set cookies and then check those every time the page loads? Quote Link to comment Share on other sites More sharing options...
jeger003 Posted December 29, 2008 Author Share Posted December 29, 2008 i tried to figure it out.......but i couldnt........i cant find how its checkin user ids..........but i figured out another way we can do it........when users log in their username is displayed as <<DISPLAY_USERNAME>> so it looks like this : Hello <<DISPLAY_USERNAME>> welcome back! so if some how we can get it to search for the username in the db.......or have it display all the ads that match the username.......because it will all be on the same page and wouldnt have to search anywhere else.......the only catch is the username and ads are not on the same table......the ads are on ads_classified which goes by user ID's and the username is on ads_userdata for example: if my user name is jeger003 and i have an ad selling a car and my user id is 23 the ads_classified table would say ID ad_title date_published 23| car for sale | 12-29-08 and the ads_userdata would say ID username email 23| jeger003 | jeger003@blah.com so i would need to some how match the ID from the ads_classified table to the username in the userdata table i hope this makes.......and i thank you for all your help Quote Link to comment Share on other sites More sharing options...
jeger003 Posted December 30, 2008 Author Share Posted December 30, 2008 Can anyone help me on this? please Quote Link to comment Share on other sites More sharing options...
Sesquipedalian Posted December 31, 2008 Share Posted December 31, 2008 Why don't you just use sessions in the login? You should be doing that anyways... When they login set a variable $_SESSION['username'] and make it there username, so that when the page loads you automatically know their username. Sessions are more secure overall -- if you have a login it would benefit you to use them. Quote Link to comment Share on other sites More sharing options...
jeger003 Posted December 31, 2008 Author Share Posted December 31, 2008 thats my problem I know nothing about putting it together........i am using sessions and have a sql table for it........but how would i be able to make it display it specific to usernames? like how would i put the "$_SESSION['username']" so that it displays their ads? Quote Link to comment Share on other sites More sharing options...
jeger003 Posted December 31, 2008 Author Share Posted December 31, 2008 does anybody know how i can set this up..........i really need this done......i tried everything and i cant figure any way to get it to display only the users current ads. Quote Link to comment Share on other sites More sharing options...
peranha Posted December 31, 2008 Share Posted December 31, 2008 can we see the login script? Quote Link to comment Share on other sites More sharing options...
jeger003 Posted January 1, 2009 Author Share Posted January 1, 2009 can we see the login script? the thing with my script is that everything is based from the index.php..........so index.php page calls all the other pages and i have no login.php.......but here is what i found on the index.php page that has to do with the login if you need more or if you need me to post the entire index.php page i can case 10: //login if (!$auth) { include_once("classes/authenticate_class.php"); $auth = new Auth($db,$language_id); if ($auth->configuration_data->IP_BAN_CHECK) $auth->check_ip($db); } if (!$user_id) { if (($_REQUEST["b"]) && (is_array($_REQUEST["b"]))) { $authorized = $auth->login($db,$_REQUEST["b"]['username'],$_REQUEST["b"]['password'],$_COOKIE["classified_session"]); if ($authorized) { if ($_REQUEST["c"]) { $c = str_replace("*is*", "=", urldecode($_REQUEST["c"])); header("Location: ".$browse->configuration_data->CLASSIFIEDS_URL."?".$c); } else { if ($auth->configuration_data->POST_LOGIN_PAGE == 0) { include_once("classes/user_management_home.php"); $user_management = new User_management_home($db,$language_id,$authorized,$classauctions); if (!$user_management->user_management_home_body($db)) $user_management->site_error($db); } elseif ($auth->configuration_data->POST_LOGIN_PAGE == 1) { include_once("classes/browse_ads.php"); $browse = new Browse_ads($db,$authorized,$language_id,0,$_REQUEST["page"],0,$filter_id,$state_filter,$zip_filter,$zip_distance_filter); if (!$browse->main($db)) { if ($debug) echo "in no main browse<Br>\n"; $browse->site_error($db); } } } } else { $auth->login_form($db,$_REQUEST["b"]['username'], $_REQUEST["b"]['password'], urldecode($_REQUEST["c"])); } } else { $auth->login_form($db); } } else { $auth->already_logged_in($db); } $db->Close(); if ($get_execution_time) get_end_time($starttime); exit; break; Quote Link to comment Share on other sites More sharing options...
jeger003 Posted January 1, 2009 Author Share Posted January 1, 2009 if you see in the code it includes authenticate_class.php I can post that page here if necessary. Quote Link to comment Share on other sites More sharing options...
jeger003 Posted January 1, 2009 Author Share Posted January 1, 2009 can anyone please helpppp meeeeeeeeeeee any advice, links woudl help Quote Link to comment 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.