-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
that's more of a css question and has nothing to do with php.
-
Man, that's some messy code... well, to start, you've opened an if statement and haven't closed it... you've also opened a foreach loop and haven't closed it. also, you cannot get the costs of each color, because you're not posting them. You're only posting the color and... in this code: if (isset($_POST['extras']) AND is_array($_POST['extras']) && (isset($_POST['color'])) { why are you using AND and && ?
-
the one inside the function probably fails because $_POST['assign'] is not set. You have a condition specifically for that. Could you please explain EXACTLY what you want to happen ? (also, consider changing fopen(), fwrite(), fclose() for file_put_contents(). it will do the same and is a better practice.)
-
I don't really get what you want. do you want them both to run, or just one or the other... if only one of them should run, based on the existence of $_POST['assign'], change last if statement to something like: if(isset($_POST) && !isset($_POST['assign'])) ... hang on.. Ignore that... I just had a better look at your code... My bad.
-
Help please-Warning: Division by zero in C!
WebStyles replied to kingsbest's topic in PHP Coding Help
You really don't need all of that. try this: include("includes/db_conn.php"); echo "<table width='700'> <tr> <td class='h5'>ref</td> <td class='h5'>last</td> <td class='h5'>first</td> <td class='h5'>grade</td> <td class='h5'>club</td> <td class='h5'>played</td> <td class='h5'>Won</td> <td class='h5'>Drawn</td> <td class='h5'>Lost</td> <td class='h5'>Points</td> <td class='h5'>&#37;</td> </tr>"; $result = mysql_query("SELECT * FROM members WHERE club='fen'"); while ($row = mysql_fetch_array($result)){ $percent = $row['played'] > 0 ? round($row['points']/$row['played']*100, 2) : 0; echo "<tr>"; echo "<td class='h5'>" . $row['ref'] . "</td>"; echo "<td class='h5'>" . $row['last_name'] . "</td>"; echo "<td class='h5'>" . $row['first_name'] . "</td>"; echo "<td class='h5'>" . $row['grade'] . "</td>"; echo "<td class='h5'>" . $row['club'] . "</td>"; echo "<td class='h5'>" . $row['played'] . "</td>"; echo "<td class='h5'>" . $row['won'] . "</td>"; echo "<td class='h5'>" . $row['drawn'] . "</td>"; echo "<td class='h5'>" . $row['lost'] . "</td>"; echo "<td class='h5'>" . $row['points'] . "</td>"; echo "<td>" . $percent. "</td>"; echo "</tr>"; } } echo "</table>"; mysql_close($con); at the en of the $percent line, where there's : 0; you can change it for : ' '; if you don't want to display anything. -
Man, too much text, links and code, I just skimmed through it. From what I understand, you want another checkbox, that will send 1 when checked or 0 when not checked. input type="checkbox" name="NEWCHEKBOXNAME" value="1" /> then on form submission use isset (unset checkboxes do not get sent with form, so if it does not exist, your value is 0, if it exists, value is 1) if(isset($_POST['NEWCHECKBOXNAME'])){ // do something, check other value, whatever... if($othervalue==1) $iscore = 1; }else{ $iscore = 0; } hope this helps
-
should be $info['filename'] and NOT $filename.
-
if your 'string' is numeric, then it's not a string... try converting to string first.
-
I agree with boompa. Basically when you insert text in a text field, line breaks are stored as '\n' but they do not work in html, so they need to be converted to '<br>'. nltobr(); will do that for you. it's similar to str_replace("\n","<br />",$text); Hope this helps
-
php search subdirectories and delete files
WebStyles replied to matt121400's topic in PHP Coding Help
You can loop through the files and search for the folders with is_dir() Of course, this depends on how many levels of folders we're talking about. if ($handle = opendir('/path/to/files')) { while (false !== ($file = readdir($handle))) { if(is_dir($file)){ // found a folder, do something with it } } closedir($handle); } -
maybe something like this: $formatted=str_pad($unformatted, 5 , "0");
-
you can simply use file_get_contents() to read the file, then use explode() to break it up. something like this: $file = file_get_contents('csvfile.csv'); $lines = explode("\n",$file); foreach($lines as $line){ $data = explode(",",$line); $name = $data[0]; $something = $data[1]; //....etc... } I'm assuming 2 things here: 1. you file uses \n as the line break character 2. it is delimited by commas (as the name CSV emplies) Hope this helps.
-
file_put_contents(); is the preferred method for writing to txt files.
-
ok, imagine something like this: (this is a very basic example) user table: `id`,`username`,`password`,`permissions` with the following values ('1','John Doe', 'xxxxx','NYNN') you also grab his permissions. You'll have a variable with the values NYNN At the top of each page you set a pageID number that refers directly to the position on the letters in your permissions field. (remember, first letter is position 0 and not 1) then you check the session variable (or cookie if you stored the info there) to see if that user can access the page he's on: session_start(); $pageID = 1; if($_SESSION['permissions'][$pageID] == 'Y'){ // ok to proceed }else{ // permission denied: show error or redirect } of course, there are much better and efficient ways to do this, but they would be hard to explain here. hope this helps
-
Query to link tables and extract team name linked to ID
WebStyles replied to ade2901's topic in PHP Coding Help
another way to solve that (and speed up your query) would be to store the team names in fixture instead of the team ids (unless there are duplicate team names) -
that sounds like a case of bad database design. From what I understand, you have (lets say 2) two different pages, that show 2 different things, and you have 1 user that has access to page 1, and a different user that has access to page 2. (correct me if I'm wrong) you should only have one users table, and a set of permissions for each user. then you can specifically say: user xxxx can access page 1 user yyyy can access page 2 user zzzz can access page1 and page 2
-
did you even try to find the answer? first page that showed up on google: http://pietschsoft.com/post/2006/06/01/JavaScript-Loop-through-all-elements-in-a-form.aspx
-
It depends, do you really need to login with 2 different users from the same machine? (even now that you know you can use 2 different browser to get the job done?)
-
in a nutshell, you want one server to send files to the other one? ftp
-
you have table {border:0} in .css files
-
this: does not work, because the correct newline character is "\n" and not "/n"
-
Query to link tables and extract team name linked to ID
WebStyles replied to ade2901's topic in PHP Coding Help
maybe a JOIN will help. here's an example: $result = mysql_query("SELECT `fixture`.*,`team`.`teamName` FROM `fixture` LEFT JOIN `team` ON `fixture`.`teamA` = `team`.`teamID`")or die(mysql_error()); This would select everything from fixture, and for each line it will grab the teamA id nr, and lookup the appropriate TeamName in a table called `team`. Check out all mysql join functions: inner join, left join, right join... hope this helps -
sounds like a cookie or session issue. I betting on something like this simplified example: 1. user logs in 2. a session variable is created (or a cookie) with username="john doe", and another one with login="ok" (or something of the sorts) 3. every time a page is accessed (or refreshed), the code looks at the 'login' variable to see if there's a user logged in (login="ok") 4. the the page grabs the username and uses that to get the rest of the information on the user. if you use the same browser (if it works fine on 2 different computers, it will work fine on 2 different browsers) to login again, the variable that holds the username is overwritten. this is basically bad design, as the login page should detect if a user is already logged in, and force a logout before allowing another one. Of course it is possible to create a system that allows multiple logins, but why? two people cannot use the same computer at the same time. Even facebook, google, etc.. will not allow you to login with 2 seperate accounts at the same time on the same computer (same browser). hope this helps
-
of course it works. its just a matter of how you store the timestamp. $_SESSION will do.
-
What is the easiest way to make this function
WebStyles replied to Bl4ckMaj1k's topic in PHP Coding Help
ok... this: $_POST['someValue'][$someVariable]; is basically an array called 'someValue' that was sent over POST method. because POST is an array itself, what you have is an array inside an array. the [$someVariable] at the end is just the index you're using to access one of the arrays values.