Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. why not do something like //you'll have to reconfigure the SQL query to work with your db setup $sql = "SELECT region, count(*) FROM wp_usermeta GROUP BY region"
  2. it's because you are running a while loop inside a while loop. so each time the first loop iterates, the 2nd while loop goes through a full cycle, and again for the 2nd iteration of the first loop etc. pull out the values from the DB into an array, and then use in_array to check if that folder is permitted... something like this, not tested though $permitted = array(); $sql2 = "SELECT url FROM url WHERE gebruiker_id =" . $id . " ORDER BY id ASC"; // Get the directory's in the db from the user $res2 = mysql_query($sql2); while ($row = mysql_fetch_array($res2)) { $permitted[] = $row['url']; } // Get directory's $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { //Get the directory's in the Album folder if($direc == '.' || $direc == '..' || $direc == 'res' || $direc == 'manifest.jmf' || $direc == 'lifeboat.zip' || $direc == 'index.html' || $direc == 'folderimage.jpg') { // Exclude some files to show } else { if (in_array($permitted, $direc)) { // When actual directory is the same as the folder $checked = "checked"; } else { $checked = ""; } echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' " . $checked . " />" . $direc . "<br />\n"; // Show it! } } closedir($handle);
  3. in the while loop you'll need an if statement checking whether the user is permitted to see that folder or not and then add checked="yes" to the checkbox input tag. Not exactly sure how you're DB is set up to correlate with the folders, i.e. //check if the user is granted permission to see folder if ($checkboxGranted==true) { echo "\t\t<input type='checkbox' checked='yes' name='map[]' id='map[]' value='" . $direc. "' />" . $direc . "<br />\n"; } else { echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' />" . $direc . "<br />\n"; }
  4. substr() $variable = "/assets/img/defaultuser.jpg"; $variable = substr($variable, 1);
  5. yes, if you want to search with one of the three you would change it to if (isset($_POST['term'])) { $term = mysql_real_escape_string($_POST['term']); $whereClause = "WHERE naam like '%$term%'"; } else if (isset($_POST['postcode'])) { $postcode = mysql_real_escape_string($_POST['postcode']); $whereClause = " WHERE postcode = '$postcode'"; } else if (isset($_POST['woonplaats'])) { $woonplaats = mysql_real_escape_string($_POST['woonplaats']); $whereClause = "WHERE woonplaats = '$woonplaats'"; } $sql = mysql_query("select * from databasetable $whereClause"); Just make sure the user knows only to search with one box, or have a select element where the user designates what they're searching for.
  6. Sorry, I left in your original where condition, and I should've enclosed the OR terms in brackets. have a play around with it - you should get the general idea now and echo the search query so you can have a good look at whats executing. if (isset($_GET['brand']) { $brand = mysql_real_escape_string($_GET['brand']); $whereClauseXtra= "AND brand='$brand'"; } else { $whereClauseXtra = ''; } $refineBrandSQL = mysql_query("SELECT a.*, COUNT(*) AS numbers FROM inventory a WHERE (item_name LIKE '%$searchTermDB%' OR item_desc LIKE '%$searchTermDB%' OR a.sub_category_b LIKE '%$searchTermDB%') $whereClauseXtra GROUP BY brand"); //echo query for debug echo "SELECT a.*, COUNT(*) AS numbers FROM inventory a WHERE (item_name LIKE '%$searchTermDB%' OR item_desc LIKE '%$searchTermDB%' OR a.sub_category_b LIKE '%$searchTermDB%') $whereClauseXtra GROUP BY brand"; $refineBrand = $refineBrandSQL or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$refineSQL}") ; if (mysql_num_rows($searchResult) > 0) { echo "<div class='headerClass3'>Brand</div>"; while ($make = mysql_fetch_array($refineBrand)){ $brand = ""; $brand .= "<a href='search.php?brand={$make['brand']}'>". $make['brand'] .' ('. $make['numbers'] .')</a><br />'; echo "<div class='left_pad'>" .$brand. '</div>'; } }
  7. so you would have something like $whereClause = 'WHERE '; if (isset($_POST['term'])) { $term = mysql_real_escape_string($_POST['term']); $whereClause .= " AND naam like '%$term%'"; } if (isset($_POST['postcode'])) { $postcode = mysql_real_escape_string($_POST['postcode']); $whereClause .= " AND postcode = '$postcode'"; } if (isset($_POST['woonplaats'])) { $woonplaats = mysql_real_escape_string($_POST['woonplaats']); $whereClause .= " AND woonplaats = '$woonplaats'"; } if (isset($_POST['probleem'])) { $probleem = mysql_real_escape_string($_POST['probleem']); $whereClause .= " AND probleem = '$probleem'"; } //ensure where clause has conditions added, if not then remove clause if ($whereClause == 'WHERE ') { $whereClause = ''; } $sql = mysql_query("select * from databasetable $whereClause"); //now do the while loop etc to echo results
  8. oh, so term is just a general term? I though you wanted to search form like address: name: telephone: etc you want the single 'term' to be found in any of the fields??
  9. that would end up searching for "SELECT * FROM table WHERE address = '$address' AND address like '%$address%'" which would return the same as "WHERE address = '$address'" You want to search for any or all of the fields, then use the first script I posted and modify it to suit You need a form with inputs for naam, address etc then use the isset() function to check if the user has put in any search terms into the textbox, if so add it to the where clause.
  10. something like this mysql_connect ("localhost", "username","password") or die (mysql_error()); mysql_select_db ("database table"); $whereClause = 'WHERE '; if (isset($_POST['term'])) { $term = mysql_real_escape_string($_POST['term']); $whereClause .= " AND naam like '%$term%'"; } if (isset($_POST['address'])) { $address = mysql_real_escape_string($_POST['address']); $whereClause .= " AND address = '$address'"; } //and continue doing this for all your form elements $sql = mysql_query("select * from databasetable $whereClause");
  11. meta keywords & descriptions aren't relied upon by many search engines anymore, they were exploited and a lot of websites would have meta keywords & descriptions such as "microsoft, NFL, superbowl" etc to try and increase their search rating. You have to add your sites manually unless other sites already listed are linking to your site; add to google here
  12. this should probably be in the php section, you'll need something like search.php if (isset($_GET['brand']) { $brand = mysql_real_escape_string($_GET['brand']); $whereClauseXtra= "AND brand='$brand'"; } else { $whereClauseXtra = ''; } $refineBrandSQL = mysql_query("SELECT a.*, COUNT(*) AS numbers FROM inventory a WHERE item_name LIKE '%$searchTermDB%' OR item_desc LIKE '%$searchTermDB%' OR a.sub_category_b $whereClauseXtra LIKE '%$searchTermDB%' GROUP BY brand"); $refineBrand = $refineBrandSQL or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$refineSQL}") ; if (mysql_num_rows($searchResult) > 0) { echo "<div class='headerClass3'>Brand</div>"; while ($make = mysql_fetch_array($refineBrand)){ $brand = ""; $brand .= "<a href='search.php?brand={$make['brand']}'>". $make['brand'] .' ('. $make['numbers'] .')</a><br />'; echo "<div class='left_pad'>" .$brand. '</div>'; } }
  13. when a user logs in, have a column in the users table named 'activity' (i'd store a unix timestamp) and each time a user visits a page include a script which will update this in the database and store the same value in the session. if this value is less than say 10minutes ago, then the script should then ask them to log in again. that way you know all your users that are logged in are those with 'activity' values within the last 10minutes. And then you can use javascript/ajax or jquery to call a refresh page every 5minutes which will refresh the 'activity' field in the database. You can set these to shorter intervals, 2mins instead of 10 etc... Just some food for thought
  14. that I did, cheers for the fix up
  15. find the position of the . then return the string after that i.e. $string = 'table.birthday'; $position = strpos('.',$string); $newString = substr($string, $position); echo $newString;
  16. you need to use ==, rather than the assigning = in this line if ($result['errorMessage'] = "") {
  17. Why is the information duplicated in the second table? I would suggest normalizing your database and removing duplicate copies of data... i.e. a NHL player table, then a seperate stats table, or even 2 stats tables if required
  18. I suggest you separate the php from the html, execute the php code at the top of the page and then assign any html it produces to a variable and call it from the html... to keep things clean and easy to follow. And another thing, when you post here use [ php ] tags rather than [ code ] **edit** my bad, you did use [ php ], just you used the shorthand <? opener, you should use the full <?php i.e. <?php //php code $myHTML = "this is the html"; ?> <html> <body> <div> <?php echo $myHTML; ?> </div> </body> </html>
  19. the other bit of code needs to be on the page that the form posts to, i.e. where you process the form data and do whatever with it try this for a bit of debugging. <?php $sql = mysql_query("SELECT * FROM Registration WHERE id='$id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event = $row["event"]; $startdate = $row["startdate"]; $enddate = $row["enddate"]; $description = $row["description"]; $location = $row["location"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; //this will echo the contents of each db row as they are iterated in the loop print_r($row); ############################# if (!empty($subevent1)) { echo "<br/>$subevent1: <input type='checkbox' name='subevent[]' value='$subevent1' />"; } if (!empty($subevent2)) { echo "<br/>$subevent2: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } if (!empty($subevent3)) { echo "<br/>$subevent3: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } if (!empty($subevent4)) { echo "<br/>$subevent4: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } if (!empty($subevent5)) { echo "<br/>$subevent5: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } if (!empty($subevent6)) { echo "<br/>$subevent6: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } if (!empty($subevent7)) { echo "<br/>$subevent7: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } if (!empty($subevent8)) { echo "<br/>$subevent8: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } } //etc etc ?>
  20. $sql = mysql_query("SELECT * FROM Registration WHERE id='$id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event = $row["event"]; $startdate = $row["startdate"]; $enddate = $row["enddate"]; $description = $row["description"]; $location = $row["location"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; ############################# if (!empty($subevent1)) { echo "<br/>$subevent1: <input type='checkbox' name='subevent[]' value='$subevent1' />"; } if (!empty($subevent2)) { echo "<br/>$subevent2: <input type='checkbox' name='subevent[]' value='$subevent2' />"; } //etc etc and then from my earlier post, to process the posted data if (is_array($_POST['subevent'])) { foreach ($_POST['subevent'] AS $event) { //do whatever with each subevent } }
  21. you mean with conditional statements...? where is the code that is echoing the sub-events, you've only posted code that echoes the event. this is a basic setup with conditional statements, you'll have to modify it to your needs $sql = mysql_query("SELECT * FROM Registration WHERE id='$id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event = $row["event"]; $startdate = $row["startdate"]; $enddate = $row["enddate"]; $description = $row["description"]; $location = $row["location"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; ############################# if (!empty($subevent1)) { echo $subevent1; } if (!empty($subevent2)) { echo $subevent2; } //etc etc
  22. could you please post your database schema? i can see you have the registration table with rows subevent1 through to subevent8, what do these subevent1...8 cells hold? i.e. what values, a foreign key to another table, or text etc? I would loop through the subevents and then echo an array of checkbox like so $subevent[1] = $row['subevent1']; $subevent[2] = $row['subevent2']; $subevent[3] = $row['subevent3']; $subevent[4] = $row['subevent4']; $subevent[5] = $row['subevent5']; $subevent[6] = $row['subevent6']; $subevent[7] = $row['subevent7']; $subevent[8] = $row['subevent8']; foreach ($subevent AS $event) { echo "<input type='checkbox' name='subevent[]' value='$event' />"; } Now when you receive the posted form, $_POST['subevent'] will be an array with all the selected values. this is the page the form posts to if (is_array($_POST['subevent'])) { foreach ($_POST['subevent'] AS $event) { //do whatever with each subevent } }
  23. will need to see code & what indicated whether or not a subevent is present (database etc)
×
×
  • 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.