Jump to content

fife

Members
  • Posts

    381
  • Joined

  • Last visited

Everything posted by fife

  1. Thank you very much for your effort. I will give this ago and get back to this post with a solved if I can do. Again thank you
  2. Hi guys Right I have a major headache of a problem. its with regards to the database design of a phrase system for languages for a client of mine. Basically the client has a website with 219 different countries. They want a new section in which they will call phrases. Within this section they want to be able to show a category..... say greetings. When greetings is clicked all of the phrases for greetings in that country come up next to the english version of that word. Let say a users is looking at emergency phrases in france. when they click phrases and then emergency they will see english phrases next to the correct French response the country languages is stored currently in the country table and has a max of 3 language ID's. ok so here is what i have tables Country Languages phrasecat Phrases idcountry idlanguages idphrasecat idphrases country_name lang_name phrasecat_name phrase idlang1 idcountry idlang2 idlanguages idlang3 idphrasecat so from here I have the phrase with the country the phrase is in and the category the phrase belongs to. I dont know where to go from here!!!! I know that every country will have their languages compared to English versions as its an english site but thats it. How do I link 2 phrases together. Whats more if a country has 3 languages. how do I show all three, in order and the english next to it? Im thinking I may need more tables but I cant figure out the design of them. Any thoughts? Any help would be much appreciated Thanks Danny
  3. Awesome thanks very much for the reply and thank you for your advice. I will try that. I think your way would be much better as its less data stored in the tables and like you said. I will be able to get to my end result much quicker. many thanks Danny
  4. Ok ill try and describe this best I can. I have a members table, a company table and a link table between the two as a member sets up a company. Also there will be a permission table as other members can be part of that company based on their permission. Members company link_mem_com permission idmembers idcompany idlink_mem_com idpermission etc etc idmembers p_name idcompany idpermission Now Im not sure how to design the next bit. Basically a member will have an area for uploading pictures. However so will a company. Then on top of that other members can be apart of that company and also upload pictures. here is my thinking for the table structure for this feature. I will create an images table with uploader_id and type. i_type will be 1 for member and 2 for company. Then I will create a tag table so a member can share an image with other members and the companies they are part of. Now. I have no idea if this is right or wrong. Can someone please help me with how to do this properly or tell me if this is a suitable option? image tags idimage idtags uploader_id idimage i_type i_type name uploader_id filename i_status Thanks All
  5. wicked thanks dude that worked. w
  6. Hi guys I have an issue some field names. there are two the same. one in my members table called name and one in my company table called name. How to I echo the name of the members over the company when the tables are joined? I have tried echo $query['members.name']; echo $query['company.name']
  7. I have this function that i have found and implemented. It belongs to a dual drop down an refreshes the second dropdown base on the first one. The function works fine but not when the page is first loaded. I does not show anything. I have to select an item out of the first drop down to refresh this second one into working. Is there anyway I can mkae the second one work correctly straight away? <script type="text/javascript" charset="utf-8"> function get_cities(networks) { $.ajax({ type: "POST", url: "select.php", /* The country id will be sent to this file */ beforeSend: function () { $("#folder").html("<option>Loading ...</option>"); }, data: "idnetworks="+networks, success: function(msg){ $("#folder").html(msg); } }); } </script> The function only works
  8. good question an im not sure. I've changed it though and now its doesnt work at all. Now its just showing the first item in the list with nothing set as selected. while ($a = mysql_fetch_assoc($res)){ echo "<option value=\"{$a[$id]}\" "; if(isset($row_rs_doc['network']) && $row_rs_doc['network']==$a[id]){ echo"selected";}
  9. First ill show the code then Ill explain the problem. thanks to everyone that helped with my last post I now have this for my function function createoptions($table , $id , $field) { $sql = "select * FROM $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)){ echo "<option value=\"{$a[$id]}\" "; if(isset($row_rs_doc['network']) && $row_rs_doc['network']==$a['id']){ echo"selected";} echo ">". $a[$field]. "</option>"; } } // and in the form I have this <select name="networks" id="networks"> <?php createoptions("networks", "idnetworks", "netname"); ?> </select> This is an edit page. I have a query that pulls the data down. If i echo out $row_rs_doc['network'] I get a number so I know that has a value. However when I view the page the item that is selected as selected is the last item in the list. The number for $row_rs_doc['network'] on the loaded page is 1 yet the selected item is ...... <select name="networks" id="networks"> <option value="24" selected>Admissions</option><option value="33" selected>Asset Management Plan</option><option value="14" selected>Capital</option><option value="23" selected>Child Trust Rep</option><option value="35" selected>Childrens Centre Rep</option><option value="19" selected>Childrens University</option><option value="7" selected>Conference</option><option value="2" selected>Core</option><option value="6" selected>CPD</option><option value="34" selected>Early Years</option><option value="32" selected>Emergency Planning</option><option value="12" selected>Forthright</option><option value="1" selected>General</option><option value="31" selected>Healthy Schools</option><option value="25" selected>High Cost</option><option value="15" selected>Home</option><option value="4" selected>Horizon</option><option value="8" selected>ICT</option><option value="28" selected>In Year Fair Access</option><option value="22" selected>LSCB</option><option value="13" selected>MADCOS</option><option value="30" selected>NCSL Rep</option><option value="26" selected>NW PHA Link</option><option value="27" selected>SACRE</option><option value="16" selected>SAPH Doc Store</option><option value="9" selected>Schools Forum</option><option value="21" selected>SEN Review</option><option value="20" selected>Social Care</option><option value="10" selected>Southport</option><option value="11" selected>Stanley</option><option value="3" selected>Strand</option><option value="29" selected>Support Services</option><option value="36" selected>Traded Services Evalution</option> </select> All i want is to show the correctly selected item which should be "general" as the value there is 1 thanks
  10. ok scratch the last 2 posts.. just relised im asking a second question. The echo has been solved by Tarential so I will ask the second bit as a new question. thanks guys
  11. Ive just noticed in the code they are all coming back as selected!!
  12. Ok I think that's nearly it. There are at least no php errors flagging up but there is an error. First ill show the code then Ill explain the problem. thanks to everyone that helped I now have this for my function function createoptions($table , $id , $field) { $sql = "select * FROM $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)){ echo "<option value=\"{$a[$id]}\" "; if(isset($row_rs_doc['network']) && $row_rs_doc['network']==$a['id']){ echo"selected";} echo ">". $a[$field]. "</option>"; } } // and in the form I have this <select name="networks" id="networks"> <?php createoptions("networks", "idnetworks", "netname"); ?> </select> This is an edit page. I have a query that pulls the data down. If i echo out $row_rs_doc['network'] I get a number so I know that has a value. However when I view the page the item that is selected as selected is the last item in the list. The number for $row_rs_doc['network'] on the loaded page is 1 yet the selected item is ...... <select name="networks" id="networks"> <option value="24" selected>Admissions</option><option value="33" selected>Asset Management Plan</option><option value="14" selected>Capital</option><option value="23" selected>Child Trust Rep</option><option value="35" selected>Childrens Centre Rep</option><option value="19" selected>Childrens University</option><option value="7" selected>Conference</option><option value="2" selected>Core</option><option value="6" selected>CPD</option><option value="34" selected>Early Years</option><option value="32" selected>Emergency Planning</option><option value="12" selected>Forthright</option><option value="1" selected>General</option><option value="31" selected>Healthy Schools</option><option value="25" selected>High Cost</option><option value="15" selected>Home</option><option value="4" selected>Horizon</option><option value="8" selected>ICT</option><option value="28" selected>In Year Fair Access</option><option value="22" selected>LSCB</option><option value="13" selected>MADCOS</option><option value="30" selected>NCSL Rep</option><option value="26" selected>NW PHA Link</option><option value="27" selected>SACRE</option><option value="16" selected>SAPH Doc Store</option><option value="9" selected>Schools Forum</option><option value="21" selected>SEN Review</option><option value="20" selected>Social Care</option><option value="10" selected>Southport</option><option value="11" selected>Stanley</option><option value="3" selected>Strand</option><option value="29" selected>Support Services</option><option value="36" selected>Traded Services Evalution</option> </select> All i want is to show the correctly selected item which should be "general" as the value there is 1 thanks
  13. barand even
  14. Brand thank you
  15. ok ive tried left left, right right, right left and left right but none of them display if there is no article in the news table
  16. I have a tripple join that is working as it should. How ever I want it to bring back all results even it there are no results in the news table. There will always be a network but not news for a network. Here is the query SELECT news.*, members.*, networks.* FROM news INNER JOIN members ON members.idmembers = news.idmember INNER JOIN networks ON networks.idnetworks = news.idnetwork WHERE news.idnetwork='".$_GET['network']."' ORDER BY news.idnews DESC Ive tried left join and right join on the second inner join but still it does not bring back any results. if there is a news item it works great but it needs to without a news item
  17. Notice: Undefined variable: row_rs_doc in /home/sites/members/edit-documents.php on line 254 is the error i get. The thing is though if i echo $row_rs_doc['network'] into the page i get a value so I know its there. further more if I echo <option value=\"{$a[$id]}\">$a[$field]</option> I get <option value="33">Asset Management Plan</option> So i know both of them are there. If i echo echo "<option value=\"{$a[$id]}\" "; if($row_rs_doc['network']==$a['id']){ echo"selected"; } echo ">". $a[$field]. "</option>"; then i get <option value="24" <option value="33" etc with that error at the end. There are no other errors on the page. Is it not something to do with the syntax? To be honest im just guessing an its driving me insane
  18. cool thanks but that brings back an error too. Here is the view source <select name="networks" id="networks"> <option value="24" <option value="33" <option value="14" <option value="23" <option value="35" <option value="19" <option value="7" <option value="2" <option value="6" <option value="34" <option value="32" <option value="12" <option value="1" <option value="31" <option value="25" <option value="15" <option value="4" <option value="8" <option value="28" <option value="22" <option value="13" <option value="30" <option value="26" <option value="27" <option value="16" <option value="9" <option value="21" <option value="20" <option value="10" <option value="11" <option value="3" <option value="29" <option value="36" Notice: Undefined variable: row_rs_doc in /home/sites/members/edit-documents.php on line 254 selected></option> </select> Basically this is the code that works echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; I just want to edit it so that if $row_rs_doc['network'] == the option id echo the selected as this row is from an edit form
  19. Im having trouble writing this code as im not very good at breaking in an out of an echo. Here is the code. It has an error somewhere in it. Ithink its something to do with the if statement as it was fine until i added that. echo "<option value=\"{$a[$id]}\" " .if($row_rs_doc['network']==$a['id']){echo"selected";} . ">$a[$field]</option>";
  20. Ok im sorry if this is not AJAX as im not too sure if it is. Basically Im trying to make duel select lists. this is different code from my previous post as no one answered so i had to find a different solution. So here it goes I have a query that poplulates the first drop down list. //header function createoptions($table , $id , $field) { $sql = "select * FROM $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } //body in a form <select name="networks" id="networks"> <?php createoptions("networks", "idnetworks", "netname"); ?> </select> next I have another field <select name="folder" id="folder"> </select> Now in a different page called select.php I have this query <?php include('../Connections/db.php'); session_start(); function createoptions($table , $id , $field , $condition_field , $value) { $sql = sprintf("select * from $table WHERE $condition_field=%s AND type='1' ORDER BY $field" , $value); $res = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($res) > 0) { while ($a = mysql_fetch_assoc($res)) $out[] = "{optionValue: {$a[$id]}, optionDisplay: '$a[$field]'}"; return "[" . implode("," , $out) . "]"; } else return "[{optionValue: -1 , optionDisplay: 'No result'}]"; } if (isset($_GET['networks'])) { echo createoptions("documents" , "iddocs" , "documentname" , "parentid" , $_GET['networks']); } die(); ?> Now back on the page with the form I call this query through the following code in the header <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#networks").change(function(){ $.getJSON("select.php",{networks: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#folder").html(options); }) }) }) </script> Now the second list is show as completely blank. Im not too sure how to trouble shoot this issue or even where to start. Can some please help
  21. ok I have a function that querys a table for information then creates a loop for a dropdown list. I really would like it done the way it is at the minute however its not working. The dropdown is empty and it stops the rest of the form after the field from loading. Error reporting brings back no errors. Here is the code //in the header function createoptions($table , $id , $field) { $sql = "select * $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } //and the form field <label for="networks" ></label> <select name="networks" id="networks"> <?php createoptions("networks", "idnetworks", "netname"); ?> </select>
  22. Solved barand and pikachu2000 thank you both
  23. ok i get this error Warning: sprintf(): Too few arguments in /home/sites/results-members.php on line 113 Query was empty which is the query above on that line
  24. ok i have a query that searches the database for members by forename, surname, school name. It works fine at the level below $result = $_POST['searchfield']; mysql_select_db($dbcon, $db); $query_rs_officers = sprintf("SELECT members.*, schools.* FROM members INNER JOIN schools ON schools.idschools = members.school WHERE ((members.mfirstname LIKE '$result') OR (members.mlastname LIKE '$result') OR (schools.schoolname LIKE '$result'))"); $rs_officers = mysql_query($query_rs_officers, $dbcon) or die(mysql_error()); $row_rs_officers = mysql_fetch_assoc($rs_officers); thats great but only if you search by actual name. Lets say the user was david. If you search david you get a result if you search da then you get nothing. I then read about opperators and changed my query to below $result = $_POST['searchfield']; mysql_select_db($dbcon, $db); $query_rs_officers = sprintf("SELECT members.*, schools.* FROM members INNER JOIN schools ON schools.idschools = members.school WHERE ((members.mfirstname LIKE '%$result%') OR (members.mlastname LIKE '%$result%') OR (schools.schoolname LIKE '%$result%'))"); $rs_officers = mysql_query($query_rs_officers, $dbcon) or die(mysql_error()); How ever this is saying my query is empty. can anyone help? thanks
  25. Hi all. Im trying to create a duel dropdown list with an ajax call to populate the second list. My first list works ok but the second list is not working at all. Here is my code the header info for the ajax call <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $(".networks").change(function() { var id=$(this).val(); var dataString = 'id='+ id; $.ajax ({ type: "POST", url: "http://www.saph.info/members/iframes/foldersquery.php", data: dataString, cache: false, success: function(html) { $(".folder").html(html); } }); }); }); </script> the first dropdown list <label for="networks" ></label> <select name="networks" id="networks" class="networks"> <?php $sql=mysql_query("SELECT * FROM networks WHERE type = '1'"); while($row=mysql_fetch_array($sql)) { $id=$row['idnetworks']; $data=$row['netname']; echo '<option value="'.$id.'" >'.$data.'</option>'; } ?> </select> then I have a page called foldersquery.php with the query for the second drop down include('../../Connections/db.php'); if($_POST['id']) { $id=$_POST['id']; mysql_select_db($database_db, $db); $query_rs_folders = "SELECT * FROM documents WHERE type = '1' AND network = '$id' "; $rs_folders = mysql_query($query_rs_folders, $db) or die(mysql_error()); while($row=mysql_fetch_array($rs_folders)) { $id=$row['iddocs']; $data=$row['documentname']; echo '<option value="'.$id.'">'.$data.'</option>'; } } I have no idea where my error is. Thanks for the help
×
×
  • 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.