Jump to content

Labrat

Members
  • Posts

    24
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Labrat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks for the help, will try and rewrite everything
  2. anyone got any suggestions?
  3. mrMarcus, thank you for the reply, at the very top of my script i am already using explode for feature3, f_id is not comma-delimited
  4. The reason for me pulling the f_id as an array is I thought I needed to do it that way in order to separate the features that have already been used. I was basically trying everything I could think of in order to distinguish which ones had been chosen from the ones that are available the query (or the way i was wanting it to do) is to pull ALL available features from the features table, then inside of the loop have checkboxes for each feature with the ones already chosen checked as default the feature3 (features previously chosen) are stored in the same column of a different table, ie. 1,2,3,4,5. the numbers there correspond to the f_id numbers in a different table which already has the numbers separated with names of each feature, ie, f_id #1 = Well/Septic tank ect. this is a classified ads script I am writting, yes I know there are plenty of others out there already written but you can`t learn how things work if you keep using someone elses scripts.
  5. the features are stored in a single column in table 1 separated by a comma f_id is the id number in table 2 that corresponds to the feature number, such as if there is a feature in table1 that has a value of 2 then the f_id in table 2 would be 2 i am grabbing the $var from the array set in $feature3 = array($row['f_id']);
  6. I am trying to prepopulate some checkboxes from two tables, the first one holds the already chosen items, the second holds ALL existing items available. Now, the first tables items consist of values such as 1,2,3,7,22 which is also the ID numbers of the second table, so I need it to show ALL available options and have a check in the ones already chosen so they can be UNchecked if need be. Any help would be greatly appreciated. Code is as follows: function my_features_checkboxesLand($features){ $feature2 = explode(",", $features); $feature3 = implode(',', $feature2); echo ' <div class="clear"></div> <div class="title">Please select the Additional features.</div> '; $result = mysql_query("SELECT * FROM features WHERE f_id IN ( $feature3 ) || f_status='1' AND land_option='1'") or die("Sql error : " . mysql_error()); $f_id = $row['f_id']; $f_name=$row['f_name']; echo $feature3. '<br><br>'; while($row = mysql_fetch_assoc ($result)){ $feature3 = array($row['f_id']); foreach($feature3 as $var) echo '<div class="cbwrapper"><label><input type="checkbox" '; if($feature3){echo $feature3. ' checked ';}elseif($feature3 !=$row['f_id']){echo ''; }; echo 'name="features[]" value="'.$row["f_id"].'">'.$row["f_name"].', '.$row['f_id'].'</label></div>'; $i++; if(($i%4) == 0){ echo '<div class="clearboth"></div>'; } } }
  7. well that didnt work, i thought the page var might be the problem so changed it and nope it still does the same thing.
  8. wait a min, think i see the problem now, the $page is being called through a switch statement, but i`m seeing now that the pagination also uses the $page variable. let me see what i can do about that and i`ll let you know. thank you for the help so far.
  9. Here is my new code with your suggestion, still comes up as a blank page. i tried it both with and without the $id = $_POST['id']; as seen on the 3rd line elseif ((select($page) == 'city_search')){ if(isset($_POST['search'])){ $id = $_POST['id']; if(isset($_POST['id'])) { $id = intval($_POST['id']); } elseif(isset($_GET['id'])) { $id = intval($_GET['id']); } else { $id = false; } echo '<center>'; $per_page = 20; $pages_query = mysql_query("SELECT COUNT(id) AS tot FROM city WHERE state_id='$id'"); $pages = ceil(mysql_result($pages_query, 0) / $per_page); $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; $start = ($page -1) * $per_page; $query = mysql_query("select * from city WHERE state_id='$id' LIMIT $start, $per_page"); echo '<div class="pag"> <a href="index.php?content=locations&section=city_add">Add City</a><br><br>'; $totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM city where state_id='$id'"),0); echo "Number of Cities Found:<font color=\"red\"><b> ".$totalres. "</b></font><br><br>"; if ($pages >= 1 && $page <=$pages) { for ($x=1; $x<= $pages; $x++) { echo ($x == $page) ? '<strong><a href="index.php?content=locations&section=city_search&id='.$id.'&page='.$x.'">'.$x.'</a></strong> | ' : '<a href="index.php?content=locations&section=city_search&id='.$id.'&page='.$x.'">'.$x.'</a> | '; ; } } echo '</div>'; echo '<div class="city_cont"> <div class="city_cols"> <div class="list_id">ID</div> <div class="list_name">Country</div> <div class="list_name">State</div> <div class="list_name">City</div> <div class="list_edit">Edit</div> <div class="list_del">Delete</div> </div>'; while ($row = mysql_fetch_array($query)) { $id = $row['id']; $country_id = $row['country_id']; $state_id = $row['state_id']; $city = $row['city']; echo '<div class="city_cols"> <div class="list_id">' .$row['id'] .'</div>'; echo '<div class="name">'; $sql1 = mysql_query("SELECT * from country WHERE id='$country_id'"); $row = mysql_fetch_array( $sql1 ); echo $row['country']; echo '</div>'; echo '<div class="name">'; $sql2 = mysql_query("SELECT * from state WHERE id='$state_id'"); $row = mysql_fetch_array( $sql2 ); echo $row['state']; echo '</div>'; echo ' <div class="name">' .$city . '</div> <div class="edit"><a href="index.php?content=locations&section=city_edit&id='.$id.'"><img src="images/edit.png" border="0"></a></div> <div class="delete"><a href="index.php?content=locations&section=city_delete&id='.$id.'"><img src="images/delete.png" height="16" width="16" border="0"></a></div></div>'; } if(isset($_POST['id'])) { $id = intval($_POST['id']); } elseif(isset($_GET['id'])) { $id = intval($_GET['id']); } else { $id = false; } if ($pages >= 1 && $page <=$pages) { for ($x=1; $x<= $pages; $x++) { echo ($x == $page) ? '<strong><a href="index.php?content=locations&section=city_search&id='.$id.'&page='.$x.'">'.$x.'</a></strong> | ' : '<a href="index.php?content=locations&section=city_search&id='.$id.'&page='.$x.'">'.$x.'</a> | '; ; } } echo '</div></center>'; } }
  10. I just don`t get it, the pagination is passing the correct id number for that state and yet the next page is blank, do not see where i need the $_GET['id'] when its passing the right id to begin with. I took out the state_id reference, I was mainly just trying that to see if it would work but it doesn`t make any difference with or without it.
  11. The state_id is from the "city" table and that value is the same as the id in the "state" table. In other words if Georgia has the id number of 8 in the state table then the state_id is 8 from the city table. In the results query i have it where state_id(from city table)=$id(form submitted) State Table ID State 8 Georgia City Table ID State_id City 1 8 whatever The results are posted from the City table, thats why the $state_id = $_POST['state_id'];
  12. Thank you for your response. I`m not quite following you, are you saying the pagination links should read like this? index.php?content=locations&section=city_search&state_id='.$state_id.'&id='.$id.'&page=2 where the state_id and the id are the same? the state_id comes from the "city" table where the id is from the "state" table. Both the state_id and the id are the same number, thats what both tables have in common. Both the state_id and the id are passing in the pagination link.
  13. Hi experts, need some assistance please. I have a search code that works great and posts the information just the way it should but the problem is when I try to go to the next page it loads an empty page even though there is more to show. The next page link seems to be correct it just is not working. Here is my code, will someone please look at it and give some advice? Thank you in advance. elseif ((select($page) == 'city')){ echo '<div class="city_search"> <h1>Search by State</h1> <form method="post" action="index.php?content=locations&section=city_search"> State: <select name="id">'; echo '<option value="" selected="selected" disabled="disabled">Select a State</option>'; $result = mysql_query("SELECT * FROM state") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo '<option value="'.$row['id'].'">'.$row['state'].'</option>'; } echo '</select><input type="submit" name="search" value="Search"></form>'; echo '</div>'; } elseif ((select($page) == 'city_search')){ // $id = $_POST['id']; // $state_id = $_POST['state_id']; if(isset($_POST['search'])){ $id = $_POST['id']; $state_id = $_POST['state_id']; echo $state_id; echo '<center>'; $per_page = 20; $pages_query = mysql_query("SELECT COUNT(id) AS tot FROM city WHERE state_id='$id'"); $pages = ceil(mysql_result($pages_query, 0) / $per_page); $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; $start = ($page -1) * $per_page; $query = mysql_query("select * from city WHERE state_id='$id' LIMIT $start, $per_page"); echo '<div class="pag"> <a href="index.php?content=locations&section=city_add">Add City</a><br><br>'; $totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM city where state_id='$id'"),0); echo "Number of Cities Found:<font color=\"red\"><b> ".$totalres. "</b></font><br><br>"; if ($pages >= 1 && $page <=$pages) { for ($x=1; $x<= $pages; $x++) { echo ($x == $page) ? '<strong><a href="index.php?content=locations&section=city_search&state_id='.$id.'&page='.$x.'">'.$x.'</a></strong> | ' : '<a href="index.php?content=locations&section=city_search&state_id='.$id.'&page='.$x.'">'.$x.'</a> | '; ; } } echo '</div>'; echo '<div class="city_cont"> <div class="city_cols"> <div class="list_id">ID</div> <div class="list_name">Country</div> <div class="list_name">State</div> <div class="list_name">City</div> <div class="list_edit">Edit</div> <div class="list_del">Delete</div> </div>'; while ($row = mysql_fetch_array($query)) { $id = $row['id']; $country_id = $row['country_id']; $state_id = $row['state_id']; $city = $row['city']; echo '<div class="city_cols"> <div class="list_id">' .$row['id'] .'</div>'; echo '<div class="name">'; $sql1 = mysql_query("SELECT * from country WHERE id='$country_id'"); $row = mysql_fetch_array( $sql1 ); echo $row['country']; echo '</div>'; echo '<div class="name">'; $sql2 = mysql_query("SELECT * from state WHERE id='$state_id'"); $row = mysql_fetch_array( $sql2 ); echo $row['state']; echo '</div>'; echo ' <div class="name">' .$city . '</div> <div class="edit"><a href="index.php?content=locations&section=city_edit&id='.$id.'"><img src="images/edit.png" border="0"></a></div> <div class="delete"><a href="index.php?content=locations&section=city_delete&id='.$id.'"><img src="images/delete.png" height="16" width="16" border="0"></a></div></div>'; } print_r($_POST); if ($pages >= 1 && $page <=$pages) { for ($x=1; $x<= $pages; $x++) { echo ($x == $page) ? '<strong><a href="index.php?content=locations&section=city_search&state_id='.$state_id.'&page='.$x.'">'.$x.'</a></strong> | ' : '<a href="index.php?content=locations&section=city_search&state_id='.$state_id.'&page='.$x.'">'.$x.'</a> | '; ; } } echo '</div></center>'; } }
  14. ok for example: Table1 has 10 ads for April with 2 approved and also has 10 ads from May that has only 1 approved, now Table 2 has 5 ads for April with 2 approve but has no ads for May. Final tally should show : Total ads = 25 April ads approved = 4 May ads approved = 1
  15. thats just it, theres not going to be an y matching entries in the tables, this is a classified ads script I am trying to write. all 3 tables have the same 3 column names (ad_id, ad_date and approved) what I am trying to do is tie all tables together and sort out the amount of ads that have been approved and not approved for each month, such as ads for April are in table 1 and table2 but theres also ads for May in those tables, I need it to join both tables and sort out the number of ads in those months
×
×
  • 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.