PHP - New To Php Coding, Advice Needed!
Hello Everyone,
I want to create my own Mafia game such as, "Infamous Gangsters" have i come to the right place Basically im new to PHP coding and i want to know a list of things before i start to learn 1.) Does it cost to create a website such as: Infamousgangsters.com? 2.) How long does it take to learn PHP coding before i have enough experience to create one? 3) Does anyone have any useful documents on PHP coding which i can read to learn basic knowledge? Many Thanks, Providence Similar TutorialsI do not proclaim to be a db expert, so I'm just looking for some good advice here. I will have multiple departments that I want to be managed on the website. Each department will only simply contain who is in charge, and all the members of that department. In the past, I've stored all this in one table like "Departments" or whatever. Since each department is basically a cookie cutter of every other department, I've thought about creating a table for each department instead. So each table name would be like "department_Hardware", "department_Software". This way if we shut down a department, all I have to do is delete that table. Which is better? Hello everyone. I have been told that PHP, javascript and html would be needed for this. So I am here to explain and ask your advice. Since being severely disabled in a car accident, I am trying to make use of what I have left. I would like to use my knowledge and try to help those who want to get back to work. I will give my time for free but the cost of using council premises must be paid for, albeit heavily subsedised by the benefits department. I will need a single page. It will need a datepicker (so I am told) where students can see what days are available and then select their chosen dates and complete their details. Then, the system will make some calculations and send me an email with the details that I can add to official paperwork and email on, to the student, the benefits department and the local council. I would also like to be able to "log in" to the page, to put the details in myself and still to send me the email with the details, as before. Should I explain everything I am trying to achieve, in one post, or can someone advise me as to which parts need which code and make separate posts in the corresponding threads? I am trying to study as much as possible and am finding this forum a great help. But, a little help or guidance in the right direction would be great. Thank you, in advance, for your help Chapter 2 homework is coded. It works and that is the main thing, but I dont just want the grade, I want want to learn php and be proficent at it. Is there anything that looks wrong, Variable names, lack off comments, things out of place. All advice is welcome.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "html://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Temperature Conversion</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Fahrenheit to Celsius Conversions</h1> <article> <?php $degFahrenheit = 0; function degreeConverter ($degFahrenheit) { //Function converts F* to C* $degCelsius = (($degFahrenheit - 32) * 5/9); $returnCelsius = round ($degCelsius, 1); return $returnCelsius; } do {//begining of loop $convertCelsius = degreeConverter($degFahrenheit); echo "<p>$degFahrenheit degrees Fahrenheit = $convertCelsius degrees Celsius.</p>"; ++degFahrenheit; } while ($degFahrenheit <= 100);//end of loop ?> </article> </body> </html> I am relatively new to PHP, trying to learn more every day. I have been enjoying using Server Side Includes in my sidebars, footer etc with good results, much handier and more efficient! I would like to do the same for the header and main site navigation. However, the main problem that I am not sure how to deal with comes from having 'active' links (differently coloured menu tab for the page the user is on) in my menu. Here is a small menu example: Code: [Select] <div class="menu"> <ul> <li><a href="nav.php" class="active">Home</a></li> <li><a href="nav2.php">About</a></li> <li><a href="products1.php">Products</a></li> <li><a href="products2.php">Products 2</a></li> <li><a href="products3.php">Products 3</a></li> </ul> </div> When the user is on the Home page, the class is set to active - i.e. a different colour. If I do a simple server side include with my navigation this will of course be across all the pages. Can anyone please advise on what I need to do to make the menu work correctly across all the pages? (have different tabs selected for each respective page). Any help / insight is much appreciated. I am after some advice about doing some rather basic things that wouldnt really be done in OOP and see if there's a better way of doing this. As I just said though I know this is not the required system just one displaying of a form but I think its really cool for just simplying OOP ( ), and I actually understand it, I always need to start off small, understand it all, before I start waffling will show you my code (in no way finished yet, as you can tell from some of the html elements but its principle works: <?php ini_set('display_errors',1); class Form{ public $to; public $user; public $email; public $subject; public $comment; function showForm(){ // displaying of form to the user: echo <<<userform <html> <head> <title>Jez's Contact Form</title> </head> <body> <form id="contact" name="contact" method="post" action="{$_SERVER['PHP_SELF']}"> <label for="">Enter something:</label><input type="text" id="user" </form> </body> </html> userform; } } if(!array_key_exists('submit',$_POST)) { $myForm = new Form; // now we construct the form: $myForm->showForm(); // print_r($myForm); } ?> If a submit button in the form hasnt been hit, then show form, later on going to do and try out some validation, just wanted some advice before I get too big for my boots as such. Any advice on improving it (obviously finishing my form off of course which is what I will do), but any further advice is greatly appreciated, Jez. I'm having a mini application developed to create A4 PDF's using PHP A key part of the project needs to be able to insert high quality graphics into the document that when printed out look really sharp Some of the graphics are variable and don't always have to be printed I just wanted to know if there was a general guide on what graphics and quality to use? The graphics I need printed print really well when put into a Word document at 300 resolution - so I can't see why there should be any problems inserting into a PDF - these graphics are PNG ones Unfortunately, if I insert the same PNG format into the PDF via the PHP code, the graphic turns out to be REALLY big Just looking for advice Thanks OM I am creating a site to display some products. For ease of updating I want it to run off a MySQL database. I have created the database and php scripts to output and input data etc. I know want to show that data in my web pages. My question is.... Is it best to insert HTML into the php output script to display the information and make the site look how I want....OR ....... should I create a template of the site in HTML and then somehow call the php output script (and the particular row of the database...) Basically... should I put the html code into the php - OR - put the php into the HTML?? I hope this make sense...... thanks Hay phpeoples (: I'm new around these parts and I'm looking for a bit of help. I'm trying to answer the following: Quote Upload task8.htm to your web site (found in the zip file you downloaded for this prac set) containing a form with a textbox to enter a customer id, a submit button and a reset button. Create the PHP page named task8.php. This page is the action of task8.htm and will receive the customer ID from the task8.htm page when it submits. Based on that submitted data task8.php should extract the order number, order date, and the shipped field for all orders placed by that customer. Sort the results in ascending order of the order date. Display the results in an appropriate table. Test the PHP script by entering a valid customer id (see your output from task 3 for the customer ids) in the text box of the form and then click submit. Verify that the results you obtain are correct by comparing the resulting data with that obtained from the tables in task 4. Change your SQL query if the data is not correct. Test the script again but this time use a customer id that does not exist. What happens? Modify your task8.php script to better handle this situation with an appropriate error message instead of displaying the table heading. Verify your results. NB: when testing try several valid customer IDs to ensure that the results are correct (never assume that just because you get output that the results are correct). this is my current HTML code: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Prac3 Task 8</title> </head> <body> <h1>Task 8</h1> <!-- for the purpose of this and subseqent tasks DO NOT modify the method of this form --> <form id="customerform" action="task8.php" method="get"> <p>please fill in the following form</p> <p>Customer ID: <input type="text" name="custID"/><br/> <p><input type="submit" value="Submit"> <input type="reset" value="Reset"></p> </form> </body> </html> and this is my current php code: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Prac 3 Task 3</title> </head> <body> <?php $conn = mysql_connect("localhost", "twastudent", "prac3"); mysql_select_db("warehouse", $conn) or die ('Database not found ' . mysql_error() ); $sql = "select * from orders"; $rs = mysql_query($sql, $conn) or die ('Problem with query' . mysql_error()); ?> <?php $custid = $_GET["custID"]; ?> <?php $row= mysql_fetch_array($rs); if ($custid == $row) ?> <table border="1" summary="Customer Details"> <tr> <th>cID</th> <th>Order number</th> <th>Order Date</th> <th>Shipped</th> </tr> <?php { ?> <tr> <td><?php echo $row["customerID"] ?></td> <td><?php echo $row["orderNumber"] ?></td> <td><?php echo $row["orderDate"]?></td> <td><?php echo $row["shipped"]?></td> </tr> <?php } mysql_close($conn); ?> </table></body></html> Currently it does not show me the records for the number that I type in. Hello.
I'm in need of help when it comes to page rendering, is it good practice to have own html file for each controller and controller->method OR 1 view file for each controller and then dynamically change content depending on the method?
My structure is like so:
controllers methods
-------------
services-> repair, car glass.....
info-> contact, about me.....
What is the best or good practice to handle the content in the view? The content is always the same.
Thanks in advance.
Hi All, I am trying create 4 dropdowns and load the values based on the value selected in the previous dropdown. I am able to do this for 3 dropdowns, but for the fourth dropdown I am no able to populate the value. Could someone help me out with this please? --------------------------------------- ajaxData_1.php <?php // Include the database config file include_once 'dbconfig_1.php'; if(!empty($_POST["solutions_id"])){ // Fetch state data based on the specific country $query = "SELECT * FROM releases WHERE solutions_id = ".$_POST['solutions_id']; $result = $db->query($query); if($result->num_rows > 0){ echo '<option value="">Select release</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['releases_id'].'">'.$row['releases_name'].'</option>'; } } else{ echo '<option value="">Release not available</option>'; } } elseif(!empty($_POST["releases_id"])){ $query = "SELECT * FROM versions WHERE releases_id = ".$_POST['releases_id'].""; $result = $db->query($query); if($result->num_rows > 0){ echo '<option value="">Select version</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['version_id'].'">'.$row['supported_version'].'</option>'; } } else{ echo '<option value="">Version not available</option>'; } } elseif(!empty($_POST["versions_id"])) { $query = "SELECT * FROM platforms WHERE version_id = ".$_POST['version_id'].""; $result = $db->query($query); if($result->num_rows > 0){ echo '<option value="">Select Version</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['platforms_id'].'">'.$row['platforms_name'].'</option>'; } } else{ echo '<option value="">Platform not available</option>'; } } ?> <?php if(isset($_POST['submit'])) { echo 'Selected Solution ID: '.$_POST['solution']; echo 'Selected Release ID: '.$_POST['release']; echo 'Selected Version ID: '.$_POST['version']; echo 'Selected Platform ID: '.$_POST['platform']; } ?>
Index_3.php <!DOCTYPE html> <html> <head> <title style="color: 000000">Solution Compatibility Matrix</title> <style> select { padding: 12px; min-width:280px; margin-top:10px; } .san{ width:280px; margin:0 auto; margin-top:90px; background-color:#FFFFFF; padding:55px; color: 000000; } label { color:#000000; margin-bottom:25px; } html{ background-color: #3399CC; } </style> </head> <body> </body> </html>
Thanks, Arun Edited April 23, 2020 by cyberRobotAdded code tags So here's my problem I'm not sure how to approach this: I have a table with user_items which are stored together separated by commas. Code: [Select] 13,12,11,9,27,15,16,22,21,23,24,26,29,30,31,32,33 Now, I have a script where the user is in a trade and I want to verify the item they are trying to trade, but is there an alternative other than grabbing all of that users' items and checking that one item with all of the records? I've tried using Code: [Select] SELECT * FROM MYTABLE WHERE user_item_id IN(33) As an example to see if it will pull the rows with that ID. It didn't seem to work, am I doing it wrong? if so, forgive me. Any suggestions/help? The main problem is I don't want to have to explode that data and use a foreach to check that one item against all of that users items, as they could have well over 500. Hi all, I am looking as a pet project to develop a review site, with the info stored in a database by id and the information grabbed bet get id and then displayed on a dynamic page, eg review.php?id=1 My question is this, if i throw keywords into the mix for each review, will search engines cache a review like this? Or would I need static pages for google etc to find the info? Thanks In short i want to use the following code below, when someone selects there option and submits it, it would bring up details from the database on this user from the selected table, can you explain what it would be called doing this so i can look it up, Sorry to be a pain, Cheers. Code: [Select] <select name="target2" id="target2"> <option value=""></option> <?php $sql = "SELECT player_id, friend_id, name, is_active FROM contacts as c JOIN players as p ON c.friend_id = p.id WHERE c.player_id = $playerID AND is_active = 1 ORDER BY name ASC"; $que = mysql_query($sql) or die(mysql_error()); while($list = mysql_fetch_array($que)) { ?> <option value="<?php echo $list['friend_id'] ?>"><?php echo $list['name'] ?></option> <?php } ?> </select> for those of you who don't know i am creating a piece of forum software called ASF. Ive done it by myself so far but as it grows i find it harder to write the code and keep organised. my code is a mess and things arent done the way they should be. So if anyone can give me advice or wants to help i could post some of the files for download. Even if you just want to have a look and let me know waht you think. Thanks Carl http://www.thevault.cz.cc Hi, basically i have data in my database i want to represent as cash, i currently put the dollar sign infront of each echo which is fine, but how would i go about adding , to the php code itself as you cannot do this from the sql database.. Hello, can someone please advice me on what scripts I will need to accomplish the following. I want users to be able to login to their personal page, on there will be items such as pdf files, jpeg files etc, that they will be able to download. Are there any free scripts out there that can do this, that anyone knows of? I don't mind paying if its a cheapish script for one of you to make for me, but money is a bit tight at the moment so a free script would be my 1st choice... Thanks for all your help Right now I have a SESSION so when users flip though pages they carry their info with them, what I'm trying to do now is that userhome.php can't be accesses unless the user just was succesful in cracking there system.. game I'm creating for those of you helping and following me while I do this! it's a virutal hacking simulation and where I'm now is that the user's passwordcracker was compared to the target systems 'systemkey' and either granted him access or didn't, if it did it displayed a progress bar then fowarded to userhome.php where the target users info will lay, right now though if I just type in userhome.php i get there without haveing the crack it.... any ideas? hello i need someone to take a look on this , General comments on the code process and how should i continue !!! [attachment deleted by admin] I have a restricted page for members of a website. This restricted area is within a directory called 'download.' There is a login form on two pages (home and support pages, found in the main menu). These pages are on the site root directory. When the user successfully logs in they are taken inside the download directory to index.php. This index.php has a different look to the site root design. I have since redesigned this page to have the same structure as the site root pages. I would love for the user to able to navigate around the main site if they wanted, and when they clicked support in the menu they would have all the download files there on the page, instead of a login form. My question is how would I implement this login so that when the user logs in the support page changes from the login page to the page with the files. I don't want to to duplicate the site within the download directory, I was hoping for an efficient method, but I am unsure how to go about it. I have made a small class to learn how to do them. This basically adds the new user to the database upon registration. I would like to know if i am doing things right or if there is a better way. Also can anyone tell me why i would use this class? Previously I just included the insert query and if statements in my main register.php page and everything worked fine. what are the advantages to using it in a class? Here is the class: <?php define ("NO_USERNAME", "Please Enter A Username"); define ("NO_PASSWORD", "Please Enter A Password"); define ("NO_EMAIL", "Please Enter An Email Address"); define ("SUCCESFULL_REGISTRATION", "Done"); define ("NO_MATCH", "Your Passwords Did Not Match"); define ("UNKNOWN_ERROR", "An Unknown Error Occured"); class User { public $user_name; public $password; public $email_address; public $password_confirm; public $processed; public $error; function user_create($user_name, $password, $email_address, $password_confirm) { if (empty($user_name)) { $this->error = NO_USERNAME; } elseif (empty($password)) { $this->error = NO_PASSWORD; } elseif (empty($email_address)) { $this->error = NO_EMAIL; } elseif ($password != $password_confirm) { $this->error = NO_MATCH; } else { $this->error = NULL; } if ($this->error == NULL) { echo "Username: " . $user_name . "<br />"; mysql_query("INSERT INTO test_members (user_name, password, email_address) VALUES ('$user_name', '".md5($password)."', '$email_address')") or trigger_error("SQL", E_USER_ERROR); $this->processed = TRUE; } } public function encryptPassword($password) { $password = sha1(md5(md5(sha1(sha1($this->password))))); } } ?> |