
Snooble
Members-
Posts
311 -
Joined
-
Last visited
Never
Everything posted by Snooble
-
Hello everyone, I've been looking for so long now, i have a program that needs either: a connection string or a .udl file This is to connect to the database. Could you please help me out... If server = sql.server.com username = username password = password db = database what would the connection string look like with that information. Thank you, Any help is MUCH appreciated. Snooble
-
you could just put a include ''; in, and write the array in there... but i'd just type them in the index file... remember, blank space doesn't matter in php. Snooble
-
hmmm... you've made it very difficult to understand what you need. I think you want to send ID's to a page that then run a query on them ID's, in that case (and taking in consideration it's local) you can just send them via GET. then putting the GET's into a variable and querying them. www.yoursite.com/pagename.php?id=2 $id = $_GET['id']; //Put Query Here (SELECT * FROM TABLE WHERE ID = $id) i think you need to take a deep breath and explain what you need on your pages. Sorry i couldn't help more. Snooble
-
woh... Erm... i still am confused, sorry. I usually just use "Select * from TABLE" etc. can i not just $id = $_GET['id'] "Select Date, Score FROM scores WHERE PaitentID = $id" Or am i far from the point. I think i understand?... Tables --------------- p = paitents s = scores --------------- So it's just to distiguish between tables. If i had scores.name and paitent.name i could simplify it to s.name and p.name? One more question since you're all damn good... I'm echo'ing out the results. i want it to look like this: Name | Date | Date1... Diagnosis | Score | Score1... DIAMD | | FirstInjection | | I have the first column done, just by creating if statements like "If ($col == Name)" and <br>'d the others but each paitent should have it's own table with as many columns as they need. Eg. If paitentID No.1 had 3 sets of scores it would have 4 columns, one with the name etc. and the other three from left to right starting with the oldest. and ending with the most recent score. (I'm assuming an ORDER BY date) Could you give me a few of the important bits of code i would need to do so. mainly the foreach or while etc. (My assumption is that i need a "while it pulls a line from the SQL table with the query |Select s.* FROM scores WHERE paitentid = 1|" Each times it pulls out a row for that id it should create a new column in the table?) Thanks for your help! If i get a few examples from this i'll get fixing the table tomorrow morning. Snooble
-
that makes complete sense to me i just am having a little trouble with your query. SELECT s.* FROM scores AS s WHERE s.patientREF = $patientID ORDER BY s.date DESC what are the "s." 's? is * a wild card? thank you for your help. So the paitent id's link the scores to the names etc. Just need the answers for the above questions. Snooble Many thanks!!!!!!!!!
-
I understand parts of that, sorry. I have one db called paitents in which i have 4 fields - Name Diagnosis DIAMD FirstInjection All of that information is added correctly using a page i made. But i assume you are suggesting when that's created i should also input the name into another database called "scores". ? So scores will be: Name Date Score ? The output to the page should look like this: Name | Date | Date1... Diagnosis | Score | Score1... DIAMD FirstInjection Bare in mind there will be 50 or more paitents in the rows. And each will have a different amount of revisits. Each revisit means i take down the date and their score. I want it to output them in order of which i input. Or by Date as that would be the same. But i think i can do the outputting. it's just the inserting, because how many fields should "scores" have, as there might be as many as 100 revisits! Thank you for your help, sorry i couldn't get back to you all until now. Snooble
-
I don't understand how that would help me? Thank you for the help. but it will work adding fields. it's just the finding "the first" empty field to put it in. If "Date" is empty put it there, if not try "Date1" if that also contains data try "Date2" etc... Thanks Snooble
-
Right does this make sense... I will have a paitent database (MySQL) each row is each paitent. Every paitent has 4 fields filled in. I want a script that adds 2 fields one called "Date" and one called "Score". but if they already have them fields i want to create "Date1" and "Score1" then if they have them i want the info to be inserted into "Date2" and "Score2" instead.... Understand what i'm thinking? I will be seeing the paitents and i want to simply be able to type the date and the score in a box with the name in a GET variable. I can do everything BUT check to see if the Date & Score fields are empty for THAT paitent. if they're not i need it to check Date1 & Score1 when it finds an empty cell i want it to input the info. I hope that explains it :S I'm really after the code that can check for a value, something like if($cell != "null") or however. but if its not empty it needs to check the Date1 field, then Date2, etc... until one is empty to insert into. Thank you ever so much, Snooble
-
spot on. Thank you ever so much. I need to buy a php book of some kind to learn all these functions! Because i go the hard way about it. I was (trying) to use explode(" ", $string); in a for each loop lol. Snooble *SOLVED*
-
Hello people, Should be easyish I output a database to the user with edit and delete options for each row. i decided to add two extra fields to my db one "Edit" and one "Delete" in each of them i enter the rows name. which i put on the end of a URL using "GET". Now this is the problem... If the name is "superman" it works fine but if it's "super man" i only get send "super to the next page. Here's the snippit of code i use to pull the db and the GET method: <?php $query = "SELECT * FROM news"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); echo "<table border='1' width='465'>\n"; echo "<tr> <th>Title</th> <th>Date</th> <th>Signiture</th> <th>News</th> <th>Edit</th> <th>Delete</th> </tr>"; $count = 0; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col => $col_value) { if($col != "Delete" && $col != "Edit") echo "\t\t<td>$col_value</td>\n"; elseif($col == "Edit"){ $arr = explode(" ", $col_value); echo "\t\t<td><center><a href=edit.php?name=$col_value>Edit</a></center></td>\n";} elseif($col == "Delete"){ echo "\t\t<td><center><a href=delete.php?name=$col_value>Delete</a></center></td>\n"; }else echo "\t\t<td>$col_value</td>\n"; } $count++; echo "\t</tr>\n"; } echo "</table>\n"; if ($count < 1) { echo "<br><br>No rows were found in this table...<br><br>"; } else { } ?> Thanks! Snooble
-
best thing'd be to (at the top of your pages you want only logged in users to see have this: if(!isset($_SESSION['username'])){ header("Location: pleaselogin.php"); } If the user has logged out and trys to go back it will take the user to "pleaselogin.php" No problem Snooble
-
well you could look at the referrer. If it refers from: THESE PAGES header etc. Would work. Snooble
-
which browser are you using, i'm assuming firefox. (form post issue) An option would be to use javascript to send back the page. (Twice if nes) Snooble
-
You can run mysql from .php pages. Just set the query into a variable like so: $sql = "PUT QUERY HERE (e.g. SELECT BLAH FROM BLAH/UPDATE diggerydoo)"; mysql_query($sql) or die ("Couldn't execute $sql: " . mysql_error()); put that in your page and you'll see, replace "PUT QUERY HERE" with the query (rolls eyes) Snooble
-
I have been trying 4 days now to create database, but I cant
Snooble replied to npsari's topic in PHP Coding Help
log into your hosting site and they should have phpmyadmin if you have sql capabilities. If not i doubt they allow you. Give MYSQL PHP FREE HOST a search on google. Snooble -
create a while loop of the sql db. add all the users' posts together and store. Or (from scratch) every time a post is stored ++ a variable/tablecell Snooble
-
if not use the UPDATE sql and just do the calc's in php: $text1 = (echo price of item) $text2 = $text1 * 0.1 UPDATE tablename SET pointsfieldname = $text2
-
that wouldnt work, you would get the ouput for file b. So i suggest hidden fields. Create a hidden field containing the POST and make the action FILEC. Also make sure file b has the right isset function. submitted would never work. Page 2: <?php if (isset($_POST['myVar'])) { if (empty($_POST['myVar'])) {$errors[] = '<font color="red">Please entera value.</font>'; } else { $myVar = $_POST['myVar']; } ?> <!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> </head> <body> <form id="form1" name="form1" method="post" action=""> <input name="variable" type="hidden" value="<?php echo "" .$_POST['myVar']; ?>" /> </form> </body> </html> Page 3: <?php echo "The variable is : .$_POST['myVar']; ?> Snooble
-
No, I need a more accurate condition. Your's is the same as mine. At the moment my statement: <?php elseif(mysql_num_rows($checkresult) != 0){ echo '<span class="registererror">(Taken) Username</span>'; } ?> Is always true. I need it to be more accurate so that if the user enters a username that's NOT in the database it executes the ELSE statement. Thanks for the responce nevertheless. Anyone? SNooble
-
<?php $check = "SELECT * FROM wmusers where username='".$_SESSION['usernamereg']."' LIMIT 1"; $checkresult = mysql_query($check); if(isset($_SESSION['usernamereg']) && strlen($_SESSION['usernamereg'] < "1")){ echo '<span class="registererror">(Empty) Username</span>'; } elseif(mysql_num_rows($checkresult) != 0){ echo '<span class="registererror">(Taken) Username</span>'; } else{ echo '<span class="register">Username</span>'; } ?> I need it to only display "(Taken) Username" when the username is taken. At the moment i get that all the time. I guess i need to add a new condition to the row check? Thank you, Snooble (Heres the checkregister.php ((The page this POST's to))) <?php include 'expire.php'; include 'sessionstartandsql.php'; $_SESSION['usernamereg'] = $_POST['username']; $_SESSION['passwordreg'] = $_POST['password']; $_SESSION['emailreg'] = $_POST['email']; if ($_POST['username'] == NULL){ header("Location: register.php");} if ($_POST['password'] == NULL){ header("Location: register.php");} if ($_POST['email'] == NULL){ header("Location: register.php");} if (!eregi('@', $_SESSION['emailreg'])) { header("Location: register.php");} $check = "SELECT * FROM wmusers where username='".$_POST['username']."' LIMIT 1"; $checkresult = mysql_query($check); if(mysql_num_rows($checkresult) != 0) header("Location: register.php"); $sql = "INSERT INTO wmusers VALUES ('".$_POST['username']."', '".$_POST['password']."', '".$_POST['email']."', '0', '0', '0')"; mysql_query($sql) or die ("Couldn't execute $sql: " . mysql_error()); ?> Thanks
-
I've never installed WAMP before. Just downloaded the package. I want to install it on my Laptop, (Running Vista 32bit) The install i have is for Vista. I have a program on the desktop now called: Web-Developer Controller So, what do i do now? I haven't done anything? Also, what is the advantage of WAMP? What is it used for? lol I do know its like your own webserver etc. But give me the most common use for it. Sorry, I'm so new to this ( Servers ). Snooble
-
array your database SELECT * FROM tablename where fieldname = value and echo from the array produced from the sql above. Many topics cover this. I suggest to search. Snooble
-
<?php if(strlen($_SESSION['usernamereg']) < 1) { thanks for that... it was causing a syntax error. Took me bloody ages lol. <?php if(strlen($_SESSION['usernamereg'] < 1)) { ^ Correct way Snooble
-
i know how the topic solved button works, thank you. Will check when i can.
-
thank you, i dont know where i got isset from :?. Thank you, I double posted because otherwise you may of thought it was fixed. an exit doesn't bring the topic to the top does it? Anyway, thank you very much for that, Snoobs