
Mutley
Members-
Posts
765 -
Joined
-
Last visited
Everything posted by Mutley
-
I know how to update a row at a time but not all at once, here is my code: update.php (This is the form and lists all the rows in the database to be updated) [code]<table align="center" width="60%"> <tr> <td>Team</td> <td>P</td> <td>W</td> <td>D</td> <td>L</td> <td>For</td> <td>Against</td> <td>Diff</td> <td>Pts</td> </tr> <?php require_once("connection.php"); mysql_select_db("rufc"); $result = mysql_query("SELECT * FROM league ORDER BY pts DESC, diff DESC"); while($row = mysql_fetch_array( $result )) { $team = $row['team']; ?> <form action="admin_updateleague.php" method="POST"> <tr> <td> <input type="hidden" name="team" value="<?php echo $row['team']; ?>"> <?=$team?> </td> <td><input class="form" type="text" size="3" name="p" value="<?=$row['p']; ?>"></td> <td><input class="form" type="text" size="3" name="w" value="<?=$row['w']; ?>"></td> <td><input class="form" type="text" size="3" name="d" value="<?=$row['d']; ?>"></td> <td><input class="form" type="text" size="3" name="l" value="<?=$row['l']; ?>"></td> <td><input class="form" type="text" size="3" name="for" value="<?=$row['for']; ?>"></td> <td><input class="form" type="text" size="3" name="against" value="<?=$row['against']; ?>"></td> <td><input class="form" type="text" size="3" name="diff" value="<?=$row['diff']; ?>"></td> <td><input class="form" type="text" size="3" name="pts" value="<?=$row['pts']; ?>"></td> </tr> <?php } ?> <tr> <td><input class="form" type="submit" value="Update League Table"></td> </tr> </form> <tr> <td> </td> </tr> </table>[/code] update_confirm.php (This is what updates the database fields) [code]require_once("connection.php"); if(isset($_POST['team'])){ $team = $_POST['team']; $p = $_POST['p']; $w = $_POST['w']; $d = $_POST['d']; $l = $_POST['l']; $for = $_POST['for']; $against = $_POST['against']; $diff = $_POST['diff']; $pts = $_POST['pts']; mysql_select_db("rufc"); $sql = "UPDATE league SET team='$team', p='$p', w='$w', d='$d', l='$l', for='$for', against='$against', diff='$diff', pts='$pts' "; mysql_query($sql); echo "The selected information was updated! "; echo "<a href='league.php'>Click here</a> to continue"; echo $sql; } ?> [/code] Now the problems are, it can't update all the fields, like every 'team', it just doesn't work, I echoed $sql and it just does one 'team' with every field ="" .... nothing. What I want it to do is load all the rows in the form update.php then update every row. Not just 1.
-
I'm wanting to order my news by date but if 3 articles are posted on 1 day, they arn't in order of time. So how do I order by id (each time it is submitted it is given an ID, latest news = biggest ID number). Something like this: [code]ORDER BY date DESC && ID DESC LIMIT 1[/code] Thanks.
-
OR A script that finds all the images in a folder and shows them as thumbnails expandable into full size ones? Small & simple script. Please help!
-
I'm looking for a simple gallery, where I can upload all the images via FTP to folders easily. However the gallery must display the images in pages/thumbnails, and have a way of seeing the image full size it also must have multi category feature, so I can have a gallery for several different topics and topics in topics like: topic1 .topicA ..topicB ...topicC topic2 .topicA ..topicB So on. It must also to be easy to integrate into my design (literally like a PHP include) and must detect when a new folder/category/image is added, does anyone know of a gallery like this? Many thanks!
-
Hurah! Finally, I've tested it and it works. Brilliant. I would really like to thank everyone that has got me through this problem. Thanks Rich. :)
-
So I've done this: [code]if($page) { $sql = "SELECT * FROM pages WHERE page_id=$page LIMIT 1"; $q = mysql_query($sql); if(mysql_num_rows($q) == 1){ while($row = mysql_fetch_array($result)){ $content = $row['content']; } }else{ $content = "You're trying to find random pages in my website!"; } echo $content; } [/code] Which still doesn't work but I havn't removed the IF statement, what would it look like as I would need to remove curley brackets to? Could you do a mock up for me please?
-
At the top of my page I have this: [code]$page = isset($_GET['page']) ? $_GET['page'] : '1'; [/code] Then further down this: [code] <?php if($page) { $sql = "SELECT * FROM pages WHERE page_id={$page} LIMIT 1"; $q = mysql_query($sql); if(mysql_num_rows($q) == 1){ while($row = mysql_fetch_array($result)){ $content = $row['content']; } }else{ $content = "You're trying to find random pages in my website!"; } echo $content; } ?> [/code] It won't work, I feel like I'm doing something obviously wrong, as Roopurt18 suggests.
-
Thanks but it isn't doing what I mean. If someone went to: www.mysite.com/index.php?id=1 It would return a website with no content because all the content is in the "pages" part of the database, so if I went to: www.mysite.com/index.php?id=1&page=2 I would see content on Page 2 for the User 1 and if I went to ?id=1&page=1 it would show page 1 of the user 1. Now what I want it to do, is if I goto www.mysite.com/index.php?id=1 for it to show what would be on www.mysite.com/index.php?id=1&page=1 See what I mean?
-
Come on you PHP Freaks, what am I doing wrong? ;D
-
Tried so many ways, I just can't get it so if it is ?id=1 it displays page 1 and if I then put ?id=1&page=2 it comes up blank, I can only get one of the other to work. I've tried this: [code]if($_GET['page']) { $sql = "SELECT * "; $sql .= "FROM pages "; $sql .= "WHERE page_id=".$page." "; $result = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); $content = $row['content']; ?> <?=$content?> <? } else { $sql = "SELECT * "; $sql .= "FROM pages "; $sql .= "WHERE page_id=1 "; $result = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); $content_empty = $row['content']; ?> <?=$content_empty?> <!--^ Content of the page ^--> <? } } } [/code] Also tried: if(!empty($page)) { and: if($page == "")) { ...but they all make ?id=1 find page 1 but if I then did ?id=1&page=2 it just comes up blank.
-
Sorry, could you explain what to do with that and how it works? Would that make it so if I put ?id=1 it would goto ?id=1&page=1 automaticly.
-
Not like that. It's all in the database, heres what I've got: [code]<? if($page) { $sql = "SELECT * "; $sql .= "FROM pages "; $sql .= "WHERE page_id=".$page." "; $result = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); $content = $row['content']; ?> <?=$content?> <? } else { echo "No Page selected" } } ?> <!--^ Content of the page ^--> [/code] That would work with ?id=1&page=1 but if someone just put ?id=1 I want it to show &page=1 automaticly.
-
How do I make it so if no &page=1 etc was put in, it would display it the first page anyway? For example you put in ?id=1&page=1 It goes to page 1 but if you put in just ?id=1 it still goes to page 1?
-
Yahoo! I have no idea how that works but I've done it, thanks alot. :D
-
I understand that, thank-you Ober but my problem is how to code it into the page? I know how to find the user, like this: [code]$ewid = $_GET['id']; if($id) { $sql = "SELECT * "; $sql .= "FROM users "; $sql .= "WHERE id=".$ewid." "; $result = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); [/code] But then how do I also do it, so it loads a page from the database with the URL? So ?id=1 would bring up that user but how would I make it so ?id=1&page=2 bring up page 2 data from the database table named "pages"?
-
[quote author=zawadi link=topic=106927.msg428302#msg428302 date=1157455943] so what you need to do is, pass the page the user ID and in the page table have a user_id colum and query data database for the page ID where the user_id = the ID in the url I.E. page.php?id=1 [quote]$sql = mysql_query("select * from pages where user_id = '$id'");[/quote] also, is the page a file or data from the page table? [/quote] The problem with that, if the user id=1 it would only show page 1, I want it so users can have lots of pages.
-
Can you explain in more detail? That's confused me alot. The database will have data in. So will I have to include the pages.php file or something?
-
http://www.phpfreaks.com/forums/index.php?action=profile;u=39022 :-\
-
Theres 2 tables in the database, 1 to store the users and 1 to store the pages for that user. The first ?ID=1 will be the user, then to get the page it will be ?PAGE=2 (for page 2 for example), so ?ID=1&?PAGE=2 I want 1 php file so when you goto the ?ID=1&?PAGE=2 it finds the user and their page, then displays them. So there can be multiple users with their own pages.
-
That's great, so what would I do here: [code] $ewid = $_GET['id']; if($ewid) { $sql = "SELECT * "; $sql .= "FROM user "; $sql .= "WHERE id=".$ewid." ";[/code] Would it look like this: [code] $ewid = $_GET['id']; $page = $_GET['page']; if($ewid, $page) { $sql = "SELECT * "; $sql .= "FROM user, page "; $sql .= "WHERE id=".$ewid. && .$page." ";[/code] That's confusing me^^. The user id and page id, are on different tables.
-
I'm wanting to have id?=1 for a page but also one for a user, so a user with the id?=1 wants to view page number 2. Obviouslly in the URL id?=1?page=2 wouldn't work, if it did how do I call it twice in my PHP?
-
The problem is with the logo image, and all the rows to the left, in FF it is fine but in IE all the rows for the logoname.gif, menu and contentheader etc are stretched. In IE the image is also higher than it should be. I've spent alot of time getting it right but to find IE doesn't show it correctly what so ever. Please help me out.
-
I tried this with no luck, adding a { to the end of one of the IF statements, which appears to be missed out: [code]<?php require_once("connection.php"); if (isset($_POST['submit'])) { if (empty($_POST['oldpass']) || empty($_POST['pass1']) || empty($_POST['pass2'])) { $error = "<p class=\"error\">All fields required!</p>\n"; } elseif ($_POST['pass1'] !== $_POST['pass2']) { $error = "<p class=\"error\">New Passwords do not match!</p>\n"; } else { // assuming you know the user's id since they are already logged in: $sql = mysql_query("SELECT * FROM users WHERE password = MD5('$_POST[oldpass]') AND id = '$id'"); if (mysql_num_rows($sql) == 1) { // password correct, set new one if (!mysql_query("UPDATE users SET password = MD5('$_POST[pass1]') WHERE id = '$id'")); { $error = "<p class=\"error\">Couldn't change password</p>\n"; } else { $success = "<p class=\"success\">Password successfully changed!</p>\n"; } else { // wrong old password $error = "<p class=\"error\">Incorrect password! Password not changed!</p>\n"; } } } echo isset($error) ? $error : ''; echo isset($success) ? $success : ''; ?> <form name="updatePass" action="" method="post"> Old Password: <input type="password" name="oldpass" value="" /><br /> New Password: <input type="password" name="pass1" value="" /><br /> Confirm New: <input type="password" name="pass2" value="" /><br /> <input type="submit" name="submit" value="Change It" /> </form>[/code] If you look on line 15 on his, the IF statement doesn't close? I still have the same problem with that ELSE statement though.
-
Fixed the bugger, thanks.
-
Nope, it still finds the entry with the data in and shows it first, I don't want it to show the one with the data in the specific field. [code]$query = "SELECT team_id, DATE_FORMAT(date,'%d-%m-%Y') AS dstamp, home, away FROM scores WHERE scorehome = '' ORDER BY date LIMIT 1";[/code] So show: team_id, DATE_FORMAT(date,'%d-%m-%Y') AS dstamp, home, away Where scorehome is EMPTY Is what I want to do.