
ngreenwood6
Members-
Posts
1,356 -
Joined
-
Last visited
Everything posted by ngreenwood6
-
I am trying to display all of the variables under a table row. my code is: <?php //include the variables include ("variables.php"); include ("db.php"); $getfrom_db = "SELECT email FROM users"; //connect to database $mysqli_connect = mysqli_connect($host,$db_user,$db_pass,$db_name) or die ("Could not connect to database"); //variable to get data to the database $result = mysqli_query($mysqli_connect,$getfrom_db) or die ("Error: ".mysqli_error($mysqli_connect)); //get the data and pull it $info = mysqli_fetch_array($result); //used for the connection to get email addresses from database $email = $info['email']; if (!$info) { echo ("No Data"); } else { echo ("$email"); } ?> The echo statement at the bottom is supposed to display all of the emails but it is only displaying the first one in the database. Does anyone have any idea how to display more than one database object.
-
I am trying to display all of the variables under a table row. my code is: <?php //include the variables include ("variables.php"); include ("db.php"); $getfrom_db = "SELECT email FROM users"; //connect to database $mysqli_connect = mysqli_connect($host,$db_user,$db_pass,$db_name) or die ("Could not connect to database"); //variable to get data to the database $result = mysqli_query($mysqli_connect,$getfrom_db) or die ("Error: ".mysqli_error($mysqli_connect)); //get the data and pull it $info = mysqli_fetch_array($result); //used for the connection to get email addresses from database $email = $info['email']; if (!$info) { echo ("No Data"); } else { echo ("$email"); } ?> The echo statement at the bottom is supposed to display all of the emails but it is only displaying the first one in the database. Does anyone have any idea how to display more than one database object.
-
I am trying to display all of the variables under a table row. my code is: <?php //include the variables include ("variables.php"); include ("db.php"); $getfrom_db = "SELECT email FROM users"; //connect to database $mysqli_connect = mysqli_connect($host,$db_user,$db_pass,$db_name) or die ("Could not connect to database"); //variable to get data to the database $result = mysqli_query($mysqli_connect,$getfrom_db) or die ("Error: ".mysqli_error($mysqli_connect)); //get the data and pull it $info = mysqli_fetch_array($result); //used for the connection to get email addresses from database $email = $info['email']; if (!$info) { echo ("No Data"); } else { echo ("$email"); } ?> The echo statement at the bottom is supposed to display all of the emails but it is only displaying the first one in the database. Does anyone have any idea how to display more than one database object.
-
If you are new to php I would suggest searching php tutorials or you can go to search google for php scripts and find something already coded. I would check out hotscripts.
-
well one error that I see is that you have left the L off of the end of level 1. can you give more detail on the error?
-
I really need some help with this if anyone has any suggestions or any help is greatly appreciated.
-
That was the point of me coming here so that I could get the help that I need. I tried looking at tutorials but sometimes a little help from above is nice. could you someone show me how to incorporate this into my code. Thanks
-
In the last file their is a variable named "$getfrom_db" that selects their email from the table users. I said it works but it only displays one.
-
I am trying to pull data from my mysql database which looks like this: Database:news table:users Inside of the table is this: email firstname lastname I have three files: the first one is list.php <?php //include the variables include ("variables.php"); include ("db.php"); //connect to database $mysql_connect = mysqli_connect($host,$db_user,$db_pass,$db_name) or die ("Could not connect to database"); //variable to get data to the database $result = mysqli_query($mysql_connect,$getfrom_db) or die ("Error: ".mysqli_error($mysql_connect)); $info = mysqli_fetch_array($result); $email = $info['email']; echo ("$email"); ?> The second one is variables.php: <?php //define the variables $get_email = Trim(stripslashes($_POST['get_email'])); $get_firstname = Trim(stripslashes($_POST['get_firstname'])); $get_lastname = Trim(stripslashes($_POST['get_lastname'])); ?> the last one is db.php: <?php //database connection settings $host = "localhost"; $db_name = "news"; $db_table = "users"; $db_user = "root"; $db_pass = ""; //email addresses from database $putinto_db = "INSERT INTO users (email,firstname,lastname) VALUES ('$get_email','$get_firstname','$get_lastname')"; $getfrom_db = "SELECT email FROM users"; //used for the connection to get email addresses from database $email = $info['email']; ?> I am trying to have it list all of the email addresses in the database. I have it working but only to a certain extent. It will list one of the email addresses. Can someone please tell me what im doing wrong?
-
actually i have three different variables. I am trying to submit a form, but if they dont submit a email, firstname and lastname it wont go through
-
I have the following code: if (!$variable) { do this } but i want something like this if (!$variable and !$variable and $variable > 1) { do this } Can someone please tell me how to make it test more than 1 variable?
-
There has got to be an easier way or if you can show me what to add to mine or how to fix it. I have this code that includes index.php everytime and it works, but the problem is that if I have two boxes it displays the boxes twice because it calls index.php to each of them if the "if" statement is true. I am a noob so any help is greatly appreciated. This is get.php: <?php //include variables include ("variables.php"); //include the database variables include ("db.php"); $mysql_connect = mysqli_connect($host,$db_username,$db_password,$db_name) or die ("Could not connect to database"); //variable to send data to the database $result = mysqli_query($mysql_connect,$getfrom_db) or die ("Error: ".mysqli_error($cxn)); $row = mysqli_fetch_array($result); $firstname = $row['firstname']; $lastname = $row['lastname']; $id = $row['id']; if (!$get_lastname) { include ("index.php"); echo ("Please enter a valid last name!"); } elseif (strtolower($get_lastname) != strtolower($lastname)) { include ("index.php"); echo ("There are no results, please enter a different last name!"); } else { include ("index.php"); echo ("$firstname $lastname your user id is $id!"); } ?> The code for index.php: <html> <head> <title>Get the Data!</title> </head> <body> <!--This is the beginning statement--> This script will allow a user to pull up the data that they previously entered! <br><br> <!--This is the form that we will be using to enter the users data--> <form name="input" method="post" action="get.php"> Enter your last name: <input name="get_lastname" type="text" id="get_lastname"> <br> <input type="submit" name="submit" value="Submit"> </form> </body> </html> This is the code for variables.php: <?php //define the variables $get_lastname = Trim(stripslashes($_POST['get_lastname'])); ?>
-
Im sure this is an easy answer for some of you guru's out there but I just cannot figure it out with google searches and everything else. I have a page where a user inputs data (first name, last name, etc.). When they dont put in that information my codes is: echo ("please input data"); However, this takes them to a new page that is blank and just says "please input data". I would like it to put "please input data on the same page as where they enter the dat. How can I do this?
-
Thanks for all your help! Like I said this is a great community!
-
Thats the problem. the users will probably enter their name in capitols but when searching I want it to just check it for both. your suggestion worked though but will it work in all cases.
-
First let me explain what is happening. A user has input data into a database. I was trying to have this data pulled back up and have it displayed. I have created a few rules. If the user doesnt put anything in, it asks them to. if it doesnt match anything tell them there are no results. the problem is that as i am testing this i put in a capital letter as the first letter and it wont find it. I have to search by using a capital. This is the part that tells it to match it (elseif ($get_lastname != $lastname)). Does anyone know how I can make it none case sensitive. Here is my code: <?php //include variables include ("variables.php"); //include the database variables include ("db.php"); $mysql_connect = mysqli_connect($host,$db_username,$db_password,$db_name) or die ("Could not connect to database"); //variable to send data to the database $result = mysqli_query($mysql_connect,$getfrom_db) or die ("Error: ".mysqli_error($cxn)); $row = mysqli_fetch_array($result); $firstname = $row['firstname']; $lastname = $row['lastname']; $id = $row['id']; if (!$get_lastname) { include ("index.php"); echo ("Please enter a last name!"); } elseif ($get_lastname != $lastname) { echo ("There are no results, please enter a different last name!"); } else { echo ("$firstname $lastname your user id is $id!"); } ?> Thanks for all your help. Great community
-
I can use mysql if that is better. I was just going through a tutorial and they were using mysqli so i started using it. Please let me know how you would do it
-
Hello all I am a noob to php and am trying to learn. I have created a database that looks like this: Database: nicks Table: users Inside of the table are these values id:auto increment(primary) firstname: varchar lastname: varchar I created a script that inserts this data into my database and it is working properly. However, what I am trying to accomplish now is to get the data from the database and display it. I am trying to let the user search by their last name. Whenever I click submit it just goes to a blank page (get.php). I have attached a zip file with my files in it. If you need anymore info please let me know. Thanks to anyone who is willing to help a total noob. [attachment deleted by admin]
-
Hello all I am a noob to php and am trying to learn. I have created a database that looks like this: Database: nicks Table: users Inside of the table are these values id:auto increment(primary) firstname: varchar lastname: varchar I created a script that inserts this data into my database and it is working properly. However, what I am trying to accomplish now is to get the data from the database and display it. I am trying to let the user search by their last name. Whenever I click submit it just goes to a blank page (get.php). I have attached a zip file with my files in it. If you need anymore info please let me know. Thanks to anyone who is willing to help a total noob. [attachment deleted by admin]
-
Thank you all so very much. With all of your help I was able to get it functioning. You are all saints. I will check out both of your links. You are gods to me.
-
I know a little bit. I knew how to echo i just dont know how to properly use it to display text from a text file on a form. If you serisously know of a good book for a beginner at php please let me know and i will read it cause i have been looking for a good one.
-
thanks for the info and all your help, but i have no idea how to echo something from php into a form. I will look it up if you do not feel like helping anymore because you helped me out alot and i appreciate it
-
Thanks for your help mad techie. I will give this a shot and see what happens. My last question is will this show the data in the form that i will be editing from the faq.txt file or do i need to add more code to do that?
-
so my code would look like this and tell me if this looks good. (faq.html) <html> <body> This is a test! <br> <?php include 'faq.txt'; ?> </body> </html> Then it would be (edit.html) <html> <form action="edit.php" method="post"> <textarea name="data"> </textarea> <input name="submit" type="submit" /> </form> <?php if(isset($_POST['submit'])) { echo "Data posted:<br />"; echo $_POST['data']; } ?> then it would be (edit.php) <?php $filename = 'faq.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> and then of course i would have my faq.txt file in which this would change. Am i right in how this looks or am i way off.
-
yeah i know but i would like to know how to get that data to show up on a form that i can edit. like i said i am a newb and i thought that the point of a forum was to help newbs and i appreciate his help and i think it is up to him to decide whether or not he would like to help