brissy_matty
Members-
Posts
27 -
Joined
-
Last visited
Never
Everything posted by brissy_matty
-
Hi All, I have a question - is it possile to import data from a sql file which has been exported from another database without using something like phpmyadmin ? Or must it be done using phpmyadmin. Also is it possible to just export data without having to use phpmyadmin or similar? Matt
-
Thanks for pointing me in the right direction this is a much better solution i wasnt aware you could actually do something like that. Much appreciated. Matt
-
Hi All, Getting stuck on a bit of a date problem. I want to display "ACTIVE" if the startdate is the current date or greater then the current date BUT less then or equal to the enddate. Basically to show if an item is active or not within a current date range. $startdate & $enddate both come from a date column in a mysql database. Below is what i thought would have worked... Apparently not.. Any ideas appreciated <?php $startdate=mysql_result($result,$i,"startdate"); $enddate=mysql_result($result,$i,"enddate"); $current=date("Y-m-d"); if ($current <= "$startdate" && $current >= "$enddate") { $status="<font color='green' face='verdana' size='1'>ACTIVE</font>"; } else { $status="<font color='red' face='verdana' size='1'>INACTIVE</font>"; } ?> Thanks Heaps Matt
-
<?php switch($_POST['guess']) { case "1": //Your code here.... break; } ?>
-
okay so i am guessing that the only way to get it display all the times where there is an unknown quantity of them - some will have 6 times others will have one or 2 - would be to setp up a loop ?
-
it's only displaying the last record because when you are "echoing" the output it is outside of the loop - so the loop has finished and its set on the last record. Least thats what i think... your code: $lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'"); while ($la = mysql_fetch_row($lala)){ $start = 0; $overall = $start+=$la[0]; } echo("$overall"); would prob be better as: <?php $lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'"); $result=mysql_query($lala); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $cost=mysql_result($result,$i,"cost"); echo "$cost<br>"; // If you need to add a zero to the front then just add a 0 before $cost $i++; } ?>
-
user_check.php <?php include_once("$sitepath/functions.php"); $sql = mysql_query("SELECT * FROM users WHERE username = '$_COOKIE[username]'") OR DIE("Sorry Theres a mysql error."); $row = mysql_fetch_array($sql); $num = mysql_num_rows($sql); //check if username exsists if($num == 0) { print("You must be logged in to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); include("$sitepath/html/footer.php"); exit; } //check cookies exsist elseif($_COOKIE[username]=="" OR $_COOKIE[password]=="") { print("You must be logged in to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); include("$sitepath/html/footer.php"); exit; } //check if password is correct elseif($_COOKIE[password] != $row[password]) { print("You must be logged in to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); include("$sitepath/html/footer.php"); exit; } $username = $_COOKIE[username]; $date = date("U"); $updatelastlogin = mysql_query("UPDATE users SET last_login = '$date' WHERE username = '$_COOKIE[username]'"); $pm = mysql_query("SELECT * FROM im WHERE sentto = '$username' AND status = 'unread'"); $npms = mysql_num_rows($pm); if($npms > 0) { print("<table class='all' width=500><tr><td><a href='$siteurl/pm/index.php'>You Have $npms New Message(s)</a></td></tr></table><BR>"); } ?> Like i said - maybe not the best code but with a little playing around i am sure you can achieve what you want. Some of this stuff won't be relevant to your usage - you will just need to remove things that arent like included headers / footers / nav and any irrelevant database fields. Cheers Matt
-
loggedin.php <?php include("config.php"); include("$sitepath/html/header.php"); include("user_check.php"); // I normally insert a refresf here if i dont wany to display anything print("Your now logged in fully.<BR><BR>"); include("$sitepath/html/footer.php"); ?>
-
functions.php <?php function lostpass_form() { global $siteurl,$sitetitle; print(" <form name='form1' method='post' action='$siteurl/lostpw.php?action=lostpass' name='lp_form' onSubmit=\"document.lp_form.lp_submit.disabled=true\"> <table width='100%' border='0' cellspacing='0' cellpadding='4' align='center'> <tr> <td>Email Address</td> <td><input name='email_address' type='text'></td> </tr> <tr> <td> </td> <td><input name='recover' type='hidden' value='recover'> <input type='submit' name='lp_submit' value='Gain The Knowledge Of My Password!'></td> </tr> </table> </form> "); } function login_form() { global $siteurl,$sitetitle,$username; print(" <form action='$siteurl/login.php?action=login' method='post' name='l_form' onSubmit=\"document.l_form.l_submit.disabled=true\"> <table width='50%' border='0' align='center' cellpadding='4' cellspacing='0'> <tr> <td width='22%'>Username</td> <td width='78%'><input name='username' type='text'></td> </tr> <tr> <td>Password</td> <td><input name='password' type='password'></td> </tr> <tr> <td> </td> <td><input type='submit' name='l_submit' value='Login To Mysite!'></td> </tr> </table> </form> "); } ?>
-
Possibly not the best code in the world but here you go: login.php <?php //Database/Mysql// $dusername = "mysite_username"; //username to connect to database $dpwd = "mysite_password"; //password to accecss mySQL $dhost = "localhost"; //your db host usually localhost $dbname = "mysite_database_1"; //db name to be accessed $conn = mysql_connect("$dhost","$dusername","$dpwd") or die ("Unable to connect to database."); $db=mysql_select_db($dbname,$conn) or die("Unable to connect to database!"); include("functions.php"); if($action==login) { if($_COOKIE[username]=="" AND $_COOKIE[password]=="") { $md5_password = md5($_POST[password]); $sql = mysql_query("SELECT * FROM users WHERE username = '$_POST[username]' AND password = '$md5_password'") OR DIE("Sorry there is a mysql error."); $row = mysql_fetch_array($sql); $numrows = mysql_num_rows($sql); if($_POST[password]=="") { //include("$sitepath/html/header.php"); print("No password Entered."); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); exit; } elseif($_POST[username]=="") { //include("$sitepath/html/header.php"); print("No username Entered."); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); exit; } elseif($numrows == "0") { //include("$sitepath/html/header.php"); print("Username and Password doesnt match!"); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); exit; } else { setcookie("username","$_POST[username]",time()+30000000); setcookie("password","$md5_password",time()+30000000); echo "<meta http-equiv=refresh content=\"2;url=$siteurl/loggedin.php\">"; //include("$sitepath/html/header.php"); print("your now being logged in!"); //include("$sitepath/html/footer.php"); } } else { //include("$sitepath/html/header.php"); print("Your are already loggedin!"); //include("$sitepath/html/footer.php"); } } if($action=="") { //include("$sitepath/html/header.php"); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); } ?>
-
hmmm I would still be stuck with the different dates. The format of the database is far from practical all the date and time columns are in varchar but i have worked around that problem - unfortunately i cannot change them due to the data being exported systematically from an msaccess database. the existing database is structured like this: Title Time Date Location Spiderman 3 1/01/1900 10:30:00 AM 31/05/2007 Location 1 Spiderman 3 1/01/1900 10:30:00 AM 31/05/2007 Location 2 Spiderman 3 1/01/1900 11:30:00 AM 31/05/2007 Location 1 Spiderman 3 1/01/1900 11:30:00 AM 31/05/2007 Location 2 The formating of the dates and times from the varchar field i am fine with in fact i have AJAX working fine for selecting a movie by location and by date which will then show the session times. But what i am after shows all the dates and session times for a movie as formated in my previous post. Its the query/queries to achieve a result like this i am stuck on - given only the location and the movie name i want it to display the dates with times for any available dates in the database i.e MON, TUE, WED etc etc depending on dates that the movie will be screening.
-
how about - <? $string='blah blah blha <img src="http://www.mysite.com/image.jpg" /> blah blah blah'; $imageurl=explode('src="http://',$string); $string=explode('"',$string); echo $string[1]; ?> There most likely is a much better way ?
-
I generally use MYSQL and cookies -- You need a login form function - a database to store this info into and then the files which do all the work for you. Normally i have a functions file which will contain the Login form and if a user isnt logged in you display the login form - if a user is logged in then you display the content a logged in member would see. This can also be done with mutiple user levels see different content etc. The files you would need (named whatever you like): * Functions - contains a set of functions you can call like login form, forgotten password etc etc * Login - the script which processes the login - user checking - form completeness etc * loggedin - the login form is sent to here and sets cookies etc but only if the login form is valid *usercheck - can be included anywhere you want a check to be made where logged in content should be displayed. - If the user is logged in it will display relevant content if they arent it will say "Need to be logged in" in the area it is included. you would also need to create a registration form, maybe a validation form, and maybe a lost password form. It can become a bit of a headache. then you need if's buts and maybes
-
Do you want to INSERT this or UPDATE ? Looks kinda like UPDATE not INSERT???
-
<? $string='blah blah blha <img src="http://www.mysite.com/image.jpg" /> blah blah blah'; $imageurl=explode('"',$string); echo $imageurl[1]; ?>
-
Hi All, I have a question im a little stuck on:- What i have is a database which contains a whole lot of movie session information. This includes the following fields - Date, Time, Movie Name, Location What i am hoping to achieve is an output similar to below (formatting isnt important) but i am stuck on the query i should be using in PHP to make this happen. I think i can achive it by having mutiple loops and loops within loops - however i am aldo thinking there is a much better solution. Remembering that a movie may be in the database like 60 times with exactly the same name just different dates and times - i only need it to extract the specific movie based upon its name and i only want to display the results from a specific location. I have no problems getting just the session times from one location based on one movie on one day. But when i want to show the results like below im majorly confused - if someone could point me in the right direction - or to a good tutorial which may be helpful it would be greatly appreaciated. ================== EXAMPLE OUTPUT BELOW ====================== PIRATES OF THE CARIBBEAN: AT WORLDS END Thursday 6th June 10:00AM 11:00AM 12:00PM 1:00PM 2:00PM Friday 7th June 11:00AM 12:00PM 3:00PM Saturday 8th June 4:00PM 5:00PM 6:00PM ======================= END OF EXAMPLE =====================
-
I have it in Ajax if that's helpful - or i can change it to just be java?
-
example below: [code]$subject = "New Password For $username"; $message = "Hi $username,\n we have reset your password. \n New Password: $random_password \n $siteurl/login.php \n Thanks! $admin_email \n This is an automated message system, please do not reply!"; mail($email_address,$subject,$message,"From:$admin_email "); echo "Your password has been sent! Please check your email!<br />";[/code] obviously change the message etc to suit yourself. Cheers Matt
-
I am not sure if this will help you but i achieved population of my drop downs via the following: On my form page the select was displayed as normal the key being the onchange event for me - when the on change executes it jumps to the function that tells it to run the php page which returns the result -- in my useage i had three drop downs one based upon another - the initial just loading values from a mysql table. <select name="example" id="example" onchange="getexample(this)"> <option value="">Select</option> </select> this is the getexample() function (well a stripped back version) function getday(sel) { var cday = sel.options[sel.selectedIndex].value; ajax.requestFile = 'getdays.php?cday='+cday; ajax.onCompletion = createday; ajax.runAJAX(); }} the creatday function below: function createday() { var obj = document.getElementById(day'); eval(ajax.response); } Hope that helps i haven't tested this stripped back version but it might give you a little help...
-
i originally thought that however quickly found when first experimenting that you can update table fields or virtually anything with an ID tag
-
3 x drop down & dynamic query results
brissy_matty replied to brissy_matty's topic in Javascript Help
are you looking to have 3 drop downs or are you trying with just two? and its resetting on the third ? -
Try: var cinemaCode = document.getElementById('sale').value; Works for me - maybe not the best way but meh!
-
3 x drop down & dynamic query results
brissy_matty replied to brissy_matty's topic in Javascript Help
Nevermind worked it out. Cheers Matt -
Deleting a mysql row just after creating it?
brissy_matty replied to Edward's topic in PHP Coding Help
Why dont you just move your INSERT INTO statement so it occurs after the following code: if (move_uploaded_file($_FILES['file']['tmp_name'], "$path$name$extension")) { echo '<p>Thank you '.$uploader.', the file \''.$name.$extension.'\' has been uploaded.</p>'; </p>'; That way the INSERT only carries out if the upload is successful. If the Upload is not successful - then no insert is carried out which removes to problem of having to delete something all together Cheers -
// Make a MySQL Connection include("config.php"); mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die (mysql_error()); $query = "SELECT * FROM photos WHERE STATUS = 'accepted' ORDER BY `hits` LIMIT 5"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are ". $row['hits'] ." ". $row['id'] .""; echo "<br />"; } Would show the five highest hits. If you want it from lowest to highest then you include DESC (descending) (smallest to highest) which is why its showing the 9's instead of the 140's Unless of course you want it in that order in which case increase the limit?