Jump to content

Gast

Members
  • Posts

    131
  • Joined

  • Last visited

    Never

Everything posted by Gast

  1. The number of records in the datbase: [code]<?php $sql = mysql_query("SELECT * FROM table"); $num = mysql_num_rows($sql); ?>[/code]
  2. Gast

    Symbol

    I have never seen a double $ used like that. The only time I can think of two $ being used next to each other is if you echoing a US price next to a variable: [code]<?php $price = "100.00"; echo "The price is \$$price"; ?>[/code]
  3. [quote author=Daniel0 link=topic=99746.msg393514#msg393514 date=1152361150] There is also a setting in php.ini called 'upload_max_filesize'. It's default value is '2M'. You can change it by running the following command in your upgrade script: [code]ini_set('upload_max_filesize','whatever size you want');[/code] [/quote] Also, check the POST_MAX_SIZE which is similar to the above. It needs to be roughly the same as UPLOAD_MAX_FILESIZE.
  4. Try this: [code]<?php $result = mysql_query("SELECT R_RoomAvailiability FROM Room WHERE R_ID = ".$R_ID." LIMIT 1") or die(mysql_error()); $row = mysql_fetch_assoc($result);  //<---error is here for some reason $R_RoomAvailability = $row['SELECT R_RoomAvailiability']; echo $R_RoomAvailability; ?>[/code]
  5. Use this instead after echoing the results: [code]<?php sort($array, SORT_NUMERIC); ?>[/code]
  6. Thanks, Ken. When I added the [b]echo $rw3['choco_name'];[/b] part, it echoes the name of the animal three times. This is not right, it has the number of stables right, but it should only echo the name once. Any other ideas? [code]<?php $q1 = "Select * from choco_stables"; $rs1 = mysql_query($q1) or die("Problem getting stables, query: $q1<br>" . mysql_error()); while ($rw1 = mysql_fetch_assoc($rs1)) {     if ($rw1['stable_user'] > 0) { // or however you test for an owned stable         $q2 = "select * from users where user_id = " . $rw1['stable_user'];         $rs2 = mysql_query($q2) or die("Problem getting owner of stable, query: $q2<br>" . mysql_error());         $rw2 = mysql_fetch_assoc($rs2);         $q3 = "select * from choco_chocobos where choco_owner = " . $rw2['user_id'];         $rs3 = mysql_query($q3) or die("Problem getting animal, query: $q3<br>" . mysql_error());         if (mysql_num_rows($rs3) > 0) { // This person owns an animal             $rw3 = mysql_fetch_assoc($rs3); echo $rw3['choco_name']; // //          more code associated with the animal //           } // //          more code associated with the owner of the stable // }     } } ?>[/code]
  7. Make a file called "delete.php", and in that file put the code that Kurt posted above, changing the table and field names to work with your database. Then wherever you want to have the delete link/button make it go to "delete.php?id=###" where ### is the ID of that particular record. For example if you were echoing each result: [code]<?php $sql = mysql_query("SELECT * FROM guestbook ORDER by id"); while($row = mysql_fetch_assoc($sql)) {     echo "<a href='delete.php?id=".$row['id']."'>Delete record</a><br />"; } ?>[/code] That should help :P
  8. [quote author=Kurt link=topic=99894.msg393687#msg393687 date=1152389751] Damn Gast, you beat me to it  ;D [/quote] Sorry about that :P
  9. [quote author=dual_alliance link=topic=99894.msg393683#msg393683 date=1152389537] Man looks so simply, feel kinda like an idiot now... [/quote] Hope it helps. You could just have a link maybe in an admin panel for each of the entries: delete.php?id=172
  10. [code]<?php mysql_query("DELETE FROM guestbook_table WHERE guestbook_id = ".$_GET['id']." LIMIT 1"); ?> [/code]
  11. Are you trying to restrict the viewing of the link to whether it is 1 or 0 in the database or for a particular type of user (say a regular user or an administrator) ? Niall
  12. Sorry, I misunderstood. That may help above, though. Yes, I have one table which stores the users, simply [b]users[/b], which contains the usual, [i]user_id, user_name, user_email[/i]. For the stables, the table is [b]choco_stables[/b]: [i]stable_id (Primary), stable_user (Foreign)[/i] Obviously the "stable_user" relates to the "user_id". And finally the actual animals, is the table [b]choco_chocobos[/b]: [i]choco_id (Primary), choco_owner (Foreign), choco_level, choco_name...[i] Hopefully that may be a little more helpful. :)
  13. Sure, below is the PHP code. I apologise if it is a little confusing... [code]<?php function showStables($user_id) { // Check if user has any stables to start with $sql = mysql_query("SELECT * FROM choco_stables WHERE stable_user = ".$user_id." ORDER BY stable_id") or die(mysql_error()); // Number of stables... $numStables = mysql_num_rows($sql); // If no stables... if($numStables == 0) { print(" <div style='width:515px; padding:5px; background-color:#EFEFEF; border:1px solid #999999;'> You do not have any stables. In order to look after your Chocobos, you will need to purchase one. However, as it is your first one, we will give you one for <b>free</b>, but in the future, if you want more, it will cost you <b>2,500 gil</b> for each one!<br /> <center> <input type='button' class='submits' style='width:200px; margin-top:15px; margin-bottom:15px; font-size:14px; background-image:url(images/orange_fade.jpg); font-weight:bold' value='Get My First Stable' /> </center> </div> "); // Already have some stables... } else { // Start variables... $counter = 1; $per_row = 2; $stableCount = 1; // Start table... $temp = '<table align="center" width="400" border="0" cellspacing="0" cellpadding="0" style="background-image:url(images/stable_floor.gif)">'; while($row = mysql_fetch_assoc($sql)) { $stableLeft = rand(1, 3); $stableRight = rand(4, 6); if($counter == 1) { $temp .= "<tr>"; } if(($stableCount % 2) == 1) { $temp .= '<td width="200" valign="top" class="stable" style="background-image:url(images/stable_background_'.$stableLeft.'.gif);">'; // Here is where each animal will be displayed on the left... $temp.= '</td>'; } else { $temp .= '<td width="200" valign="top" class="stable" style="background-image:url(images/stable_background_'.$stableRight.'.gif);">'; // Here is where each animal will be displayed on the right... $temp.= '</td>'; } if($counter == $per_row) { $temp .= "</tr>"; $counter = 1; } else {  $counter++;  } // Increase counter $stableCount++; } if($counter != 1) {  while($counter <= $per_row) {  // Odd number of stables? if(($numStables % 2) == 1) { $temp .= ' <td valign="top" class="stable" style="background-image:url(images/stable_background_dull_right.gif);"> &nbsp; </td> '; $counter++; } $temp .= "</tr>"; } } $temp .= "</table>"; print($temp); } } ?>[/code]
  14. I know it sounds stupid, but let me explain. For a project myself and obsidian are working on, I have come across a problem. I wont explain the whole project here but here is the problem: I need to display 6 "stables", in as in three rows of two. I have done this with HTML, however each user will at some point buy these "stables" so they need to be dynamic, as some of them have a different background image as they are unavailable. They may only have bought 3 stables, so the first two of the stables on the first row are available, and the first on the second row. This is a little hard to explain in words, so: Available | Available Available | Unavailable Unavailable | Unavailable This is all OK, I have managed to generate all the stables with some available and some unavailable depending on how many the user has bought. But here comes the problem.... The user will have an "animal" that will be in one of the stables. However, they may not have an animal in all of their available stables. Both the stables and animals are stored in a database, so I run the query to get the stables and in a while() loop echo the actual stables in HTML. But I need to then run the query for the "animals" to be in the stables at the same time. I dont think it is possible to run two conditions in a while() loop, and the way the HTML is constructed I cannot put the loop inside the other. PLEASE HELP! I can provide a link and code if needed.
  15. Yeah do that to see if it displays correctly... Is this a MySQL database or some other kind? I am not familiar with the "db_exec" function...
  16. Take a look at what the table name that holds the posts are and what fields it has.
  17. A simple way round is to set to value of the options to: [code]<option value="1|United States" style="padding-left: 20px; background: url(../img/flags/1.gif) no-repeat;" selected>United States</option> <option value="2|Norway" style="padding-left: 20px; background: url(../img/flags/2.gif) no-repeat;" >Norway</option>[/code] Now that the value is set to "1|United States" and all the others would be similar. When you submit the form, the value of the select field if it was called "country" for example: [code]<?php // The value of the countries above split by the pipe (|) character $country = explode("|", $_POST['country']); // The var $country is now an array $country_id = $country[0]; $country_name = $country[1]; // Then run your MySQL query mysql_query("UPDATE..."); ?>[/code] Hope that helps. :)
  18. the MySQL. Do you have access to your database?
  19. The only thing I can see is that your UPDATE query doesnt have a WHERE clause. You need to update the record only with the ID passed through the URL.
  20. This should be moved by one of the mods to third-party scripts as it is asking for support using SMF. I havent used SMF before, but take a look at the database I find out the structure and then post it here, then I will be able to help you with the query.
  21. Why not use a mixture of PHP and JavaScript? [code]<input type="button" onclick="window.open('help.php?content=whatever');" /> /* On the help.php popup */ <?php if(isset($_GET['content'])) {     switch($_GET['content']) {         case "abc" :             echo "page content";             include("relevant_file.html");             break;     } } ?> [/code]
  22. You can do it in PHP. Store it in a database and then fetch it from the database, echoing it out separated by commas, and make sure you have this at the top: [code]<?php header("content-type: text/csv"); ?>[/code]
  23. Well I personally like it. It makes a change from everyone using IPB, and I am only really used to using vBulletin, IPB and phpBB
  24. Also Barand, you have probably worked it out now, but for URL tags you can also link normal text by: [nobbc][url=http://www.nmcmahon.co.uk]My Website[/url][/nobbc] Which produces: [url=http://www.nmcmahon.co.uk]My Website[/url]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.