Jump to content

mds1256

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by mds1256

  1. Hi I think im going crazy! a while back i'm sure i remember reading that you could run a 'select update' query so you could see what the results would look like before actually running the query. I cannot rember how to do it so could you please point me in the right direction
  2. Thanks, understand what you mean Im just learning this stuff so advice is welcoming
  3. thanks for the info, now got my head around why and when you would use a linking table for your second comment, what is gained from putting them in one table? just thought it would be better to seperate data out like that?
  4. Hi Just working on a bit database design and have the following scenario: users Table = Contains ID, username and password personDetails Table = contains ID, userid, first name, surname, DoB Now when linking the table e.g. to return First and Surname for a specific username is it better to have a linking table as well, so for example (pseudo speak) Select firstname, surname from personDetails, users where personDetails.userid = users.id Or have another linking table and that to contain: id userID personDetailsID and use this to link, or does it not matter which way you link?
  5. a quick mockup index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> <div id="header">Header</div> <div id="contentWrapper"> <div id="left">Left</div> <div id="right">Right</div> </div> </div> </body> </html> style.css body{ margin:0; } #wrapper{ position:relative; width:800px; margin: 0 auto 0 auto; } #header{ height:150px; border:#000000 1px solid; margin-bottom:10px; } #contentWrapper{ border:#000000 1px solid; height:512px; } #left{ margin: 5px 5px 5px 5px; float:left; width:570px; height:500px; border:#000000 1px solid; } #right{ margin: 5px 5px 5px 5px; float:right; width:200px; height:500px; border:#000000 1px solid; }
  6. Hello for my website i need to use variables from the select statement located in the code below, e.g. the account status (locked out etc). I hear global variabes are a NO NO. I have utilised session variables, is this the best way to achieve this? The code below sets a sessions variable if the user is locked out but on my home page i have just wrote an 'if' statement is see if this variable matches the criteria (if so then print out the DIV), is there a better way of doing this. function loginform($myusername, $mypassword, $ip) { $trimmedmyusername = trim($myusername); if($trimmedmyusername != "") { $sql="SELECT * FROM users, personal_details WHERE users.username='$trimmedmyusername' and users.password='$mypassword' AND users.username = personal_details.username"; $result=mysql_query($sql); $count=mysql_num_rows($result); $row = mysql_fetch_array($result, MYSQL_BOTH); if(lockout($trimmedmyusername)==1) { $_SESSION['accountstatus'] = "lockedout"; } elseif($count==1) { $_SESSION['myusername'] = $trimmedmyusername; $_SESSION['mypassword'] = $mypassword; $_SESSION['myname'] = $row['firstname']; $_SESSION['lastname'] = $row['lastname']; $_SESSION['title'] = $row['title']; $_SESSION['lastlogin'] = $row['lastlogin']; unset($_SESSION['accountstatus']); loginsucess($trimmedmyusername, $mypassword, $ip); } else { unset($_SESSION['myusername']); $_SESSION['myusername'] = $trimmedmyusername; loginfail($trimmedmyusername, $mypassword, $ip); $_SESSION['accountstatus'] = "incorrectdetails"; } } else { unset($_SESSION['accountstatus']); unset($_SESSION['myusername']); echo "Please enter a username"; } } <?php if(isset($_SESSION['accountstatus'])) { accountstatus($_SESSION['accountstatus']); } else { accountstatus(""); } ?> function accountstatus($status) { if($status == "lockedout") { echo "<div id='lockedoutimage' style='background:url(lockedout.jpg) no-repeat;'></div>"; } elseif($status == "incorrectdetails") { echo "<div id='lockedoutimage' style='background:url(incorrect.jpg) no-repeat;'></div>"; } else { echo ""; } }
  7. the while loop.... remove the semicolon and it works while ($line = mysql_fetch_assoc($results)); { should be while ($line = mysql_fetch_assoc($results)) {
  8. change to this include: <? function noms() { $foobar = "apples"; return $foobar; } ?> main: <? include("include.php"); echo "these ". noms(). " are most delicious... OM NOM NOM"; ?> that should work, use the return statement within the function have been advised (from people on this site) not to use global variables.... What i am doing when needing to return multiple variables from a function is to return an array of variables needing to be accessed, then pull back the array with the required index when needed. e.g. <?php function test() { $a = 5; $b = 10; $arr = array($a, $b); return $arr; } $returnedArr = test(); echo $returnedArr[0]; echo "<br/>"; echo $returnedArr[1]; echo ?>
  9. until it is automatically closed when the script execution ends on the current page request. Sorry thats what i meant
  10. I have created a function to connect to a required database with a username and password. I have called this db_openConnection() Now for each function that requires a select from a database is it ok just to call the db_OpenConnection() first within the function or should i be keeping open a db connection (using persist, i think) rather than keep creating a connection. I know that the connection ends when you have finished a query any how. Not sure if this is the correct forum or if it should be mysql forum
  11. Ok understood Many thanks for taking the time to reply
  12. The reason why im asking is, i am wanting to create a php function to return some data from a mysql database using a select statement but this data may be echo'ed many times throughout the site e.g. a name, job title, DoB etc. Or should i use session variables so calling the function once to return the data and store this in a session and call back the session variable each time it needs echoing. What are the pro's and cons of the above
  13. Hello I have a question (that i think i know the answer to). What would be more efficient: 1. Create a global variable and run a php function and store result in there and call back the variable when needed 2. just echo the return value of the function when needed Now im guessing that calling the function once and storing that in a variable rather than keep calling the function is more efficient
  14. strange, be better if you could post your html as well as your css see the following a very basic layout..... HTML <html> <head> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> <div id="header"></div> <div id="left"></div> <div id="main"> <p>asdasdasd</p> <p>asda</p> <p>sd</p> <p>asda</p> <p>sd</p> <p>asdasdfsdf</p> <p>sdf</p> <p>sdf</p> <p>sd</p> <p>fs</p> <p> </p> <p>dfs</p> <p>df</p> <p>sd</p> <p>fs</p> <p>df</p> <p>sf</p> <p>ds</p> <p>f</p> </div> <div id="right"></div> <div id="footer"></div> </div> </body> </html> CSS body{ margin: 0; } #wrapper{ position:relative; margin: 0 auto 0 auto; width:800px; height:100%; } #header{ background:#000099; width:800px; height:150px; } #left{ background:#FF0000; float:left; width:16%; height:200px; } #main{ background:#0099FF; float:left; width:66%; margin-left:1%; } #right{ background:#00CC00; float:right; width:16%; height:200px; margin-left:1%; } #footer{ background:#663366; clear:both; height:100px; }
  15. the divs that are now left aligned which should be centred between the two side bars, are these seperate and what are their names (ids)
  16. the main div's that are aligned to the left, what are these called (what id do they have) You will need to give that a margin-left of 16%+spacer so if it is currently 2% space then add margin-left:18% this should push them inline with the main div at the top
  17. adjust the sizes and add a margin e.g. Left = 16% Middle = 66% Right = 16% You have 2% left over.... this isnt a lot so it will look tight any how. give the middle a margin-left of 1% and give the right a margin-left of 1% thus using up the 2% but like i say 1% between them isnt a lot so it will look tight..... recommend reducing the size of the middle box and add that to the margins.
  18. left sidebar needs to be floated left main content box needs to be floated left right side bar needs to be floated right
  19. Dont worry I was totally useless at CSS until a few months ago when I eventually understood the box model and now can quickly setup a layout... The code above is just a starting point and was quickly knocked up to show you the principles. If you need the main content box to expand down etc you will have to change the height of the container to 100% and so on. It was just to show you how it can be achieved. The hardest part about CSS is learning all the different browser hacks you need to do!, its a nightmare and im still learning this as im going.
  20. think you need to learn the box model CSS #container{position:relative;border:2px solid blue;margin: 0 auto 0 auto;background-color:silver;height:800px;width:800px;}#header{background-color:#B0C4DE;height:120px;margin:0;}#left{float:left;background-color:#B0C4DE;width:120px;height:600px;}#main{float:left;background-color:white;width:560px;height:600px;}#right{float:right;background-color:#B0C4DE;width:120px;height:600px;}#footer{clear:both;border:1px solid black;height:79px;width:800px;} HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" ><link rel="stylesheet" href="style.css" type="text/css"><title>My Goggie</title></head><body><div id="container"><div id="header">Header</div><div id="left">Left</div><div id="main">Main</div><div id="right">Right</div><div id="footer">footer</div></div></body></html>
  21. shouldnt the line: $query = "SELECT * FROM league_news WHERE id = id"; look more like: $query = "SELECT * FROM league_news WHERE id = $id";
  22. Sorted - used "min-width:" and a fix for IE6 using java script expression
  23. Hi I have a header div on my website that spans the whole window. Within the header i have 2 further divs, one called text (which is floated to the left) and one called form (which is floated to the right). Within the text div i have a sentence (something like; welcome to my site guest). And in the form div i have 2 text fields and a login button. This looks spot on when window is maximised but when window is made smaller the form text fields wrap around the text that is floated on the left. What i need to acheive is when the window is made smaller the text fields will butt up against the text (on the same line and not wrap) and both text fields need to stay inline and not wrap. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> body{ margin:0 0 0 0; } #header{ background:#999999; height:30px; width:100%; } #text{ float:left; width:200px; } #form{ float:right; width:360px; } </style> </head> <body> <div id="header"> <div id="text">Welcome to my site Guest</div> <div id="form"><input name="username" type="text" /><input name="password" type="text" /><input name="Submit" type="submit" value="Submit" /></div> </div> </body> </html>
  24. Sorry your correct, i missed the 2nd part of the line below
×
×
  • 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.