Jump to content

Kelset

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by Kelset

  1. Ok not sure if this is right spot for this, I'm sorry if it it. I have session that work great on my test server (WAMP5) the move from page to page like they should. When I put them up on live server they don't seem to work? any idea's what might be wrong? Thank you for your help in this for me Stephen
  2. Works perfectly thanks for all your guys help, I am once again in debt to you have phpfreaks help pages :) I hope one day to return the favor! Cheers! Stephen
  3. Thanks for the information guys but when I run the fucntion I get an error. Call to undefined function celi() any idea why I am getting this? I figured it out should be ceil() Stephen
  4. Ok I have an array that I page through, I pass the current page throug the URL. What I am having trouble with is finding what the last page would be. First I count the number of items in the array, I then divied that by 10 (number of items showing per page) and round it. This method does not seem to be working, any ideas? cheers! Stephen
  5. Name all the checkboxes the same and then loop through them to see what ones have been checked. Name them all something like this [code] <INPUT TYPE='checkbox' NAME='cat[]' value='hotel'> <INPUT TYPE='checkbox' NAME='cat[]' value='bars'> <INPUT TYPE='checkbox' NAME='cat[]' value='restaurants'> [/code] This will put all the checkboxes into an array when form is submitted, array name being cat. On the page where you want the checkbox ticked you just use a for loop. [code] if(in_array("hotel",$cat)) {     $hotel_check = "checked"; }else{     $hotel_check = ""; } if(in_array("bars",$cat)) {     $bars_check = "checked"; }else{     $bars_check = ""; } if(in_array("restaurants",$cat)) {     $restaurants_check = "checked"; }else{     $restaurants_check = ""; } [/code] Then have the checkbox HTML look something like this [code] <INPUT TYPE='checkbox' NAME='cat[]' value='hotel' <?PHP echo $hotel_checked; ?>> <INPUT TYPE='checkbox' NAME='cat[]' value='bars' <?PHP echo $bars_checked; ?>> <INPUT TYPE='checkbox' NAME='cat[]' value='restaurants' <?PHP echo $restaurants_checked; ?>> [/code] This is just from the top of my head and nothing is tested, I'm sure there is a better way to do the if statments but i'm new. Sorry for not being able to optomized better but like I said I'm a newb :) Hope I was of some help Cheers! Stephen
  6. Just a quick stab in the dark here and I'm new but should this line contain the filename? [code] $upload_file_path = $_POST["filedirectory"] . $_POST["filename"]; [/code] The path for the file to be uploaded should not have the file name in it right? not sure Cheers! Stephen
  7. When they login I have a check user page that sets a bunch of stuff. Once of those things is the session for hold an array. I defined it just by doing this. $_SESSION['five']; Should I do it like this $_SESSION['five'] = array(); Thanks for the help Stephen
  8. I'm sorry :( Ok the error I'm getting is this. Warning: in_array() [function.in-array]: Wrong datatype for second argument in G:\wamp\www\littlecreations\display.php on line 38 Line 38 is if (in_array($five[$i], $sess_five)){ any ideas why I'm getting this error? says that it is wrong type but $sess_five is an array as far as I know. I set the session when they login to be empty $_SESSION['five'] should it be set different way? Thank you for you time in this for me Cheers! Stephen
  9. Ok i'll just post my code and see what you guys think, here is what I'm trying to do frist. The user log in to the images display page, image for that user is dispalyed and each image has a checkbox with the name of five. They select the images they would like to keep they hit a form button called "Add Image". This code fires when that button is hit, there is some paging of images and stuff but this is all I think needs to be shown. [code] //Convert session array into easy to use var $sess_five = $_SESSION['five']; //Store checkbox array in var for easy use $five = $_POST['five']; //This will be an array from checkboxes //check to see if any photos have been checked //Get number of checkboxs checked if (!empty($five)) {     //count how many images in each array $five_count = count($five);     //loop through each array and see if the value is already stored in it for ($i=0;$i<$five_count;$i++) { if (in_array($five[$i], $sess_five)){ echo " YOU HAVE ONE"; // Just some testing text }else{ //add to session var $sess_five .= $five[$i]; }//End if }//End for }//End if //Store the array back into a session $_SESSION['five'] = $sess_five; [/code] any help would be great! cheers! Stephen
  10. Kelset

    Form help

    No I use the page for displaying and storing the arrays Cheers! Stephen
  11. Kelset

    Form help

    ok I have a PHP array that displays images and I only show 10 at a time. Each image has three checkboxes for three different sizes. The paging I do works fine but it is not submitting the form so the checkbox arrays are not being sent. So what I am doing now is letting them check the sizes of the current images display and having them use the from submit button. Once they hit the button the images are loading into a session array and the next set of images is displayed. Is there a better way to do this? Just wondering. Cheers! stephen
  12. Not sure what you are looking for here, do you want all the information in one row for each record? The code above puts the information into three rows. I a very new to PHP but this is something that I might do, code is not tested. [code] <?php //Start row count at 0 $row_count = 0; //Start your table echo"<TABLE border ='1'><TR>\r"; while($row = mysql_fetch_array($query, MYSQL_ASSOC)) { //Check row_count to see if there should be a new table row made or and col. if ($row_count < 2) { //See if there are no more records, if not put in the blank col. if ($row['img_url'] == "") { echo "<td></td>\r"; }else{ echo "<td width=\"320px\"><a href=\"".$row['img_url']>"\" target=\"_blank\"><img src=\"">$row['img_url']."\" height=\"200\"/></a></td>"; echo "<td width=\"150px\">".$row['full_name']."</td>"; echo "<td width=\"150px\">".$row['description']."</td>"; } //Increment row_count by 1 $row_count++;   }else{   if ($row['img_url'] == "") { echo "<td></td></tr><tr>"; }else{ echo "<td width=\"320px\"><a href=\"".$row['img_url']>"\" target=\"_blank\"><img src=\"">$row['img_url']."\" height=\"200\"/></a></td>"; echo "<td width=\"150px\">".$row['full_name']."</td>"; echo "<td width=\"150px\">".$row['description']."</td>";         echo"</TR><tr>\r"; }     // $row_count = 0;   } } ?> [/code] Hope that helps you out in some way Cheers! Stephen
  13. Only thing I can think of is to add the NOT NULL at the end of you query. $sql = "ALTER TABLE `character` CHANGE `character` `description` varchar(255) NOT NULL"; not sure if that helps any but  I tried Cheers! Stephen
  14. If you have the DB made all you do in PHPMyAdmin is hit the insert tab at the top. Then insert the numbers you want to use in the numer colum. Cheers! Stephen
  15. Here is a function that I have found and use, it gets all the images from a directory and passes it back as an array. You can then loop through the array and make your link or what have you. function getImagesList($path) {     $ctr = 0;     if ( $img_dir = @opendir($path) ) {         while ( false !== ($img_file = readdir($img_dir)) ) {             // can add checks for other image file types here             if ( preg_match("/(\.gif|\.jpg)$/", $img_file) ) {                 $images[$ctr] = $img_file;                 $ctr++;             }         }         closedir($img_dir);         return $images;     }     return false; } cheers! Stephen
  16. Did you try to echo your query to see what it looks like? I don't know much about select a db but I don't have the $conn when I do it. I just do it this way mysql_select_db("database_name"); Other then tha I am not sure it all looks good to me :( Stephen
  17. Did you populate the DB with the numbers you want to use? If you didn't then this query would be empty. Would that not not cause your "There are no numbers left" to come up. Just guessing here, I a new to PHP $query = mysql_query("SELECT * FROM table WHERE `user`=''");\ Cheers! Stephen
  18. Just run a query looking for that IP, just guessing here I'm a newb :( $sql = "Select ip_col FROM TABLE WHERE ip='users_ip'"; I take it your doing this through a login? Hope I was some help Cheers! Stephen
  19. So the checkboxes are going to be a admin kind of thing? and when the player goes to his members profile he will see a list of images that are his medals. Sounds easy enough and I think mjdamato has it right :) Just set the check box to true or flase with default being false. Then make the check box have a value of true when checked. On the members profile just do a check on the medals col and display the ones marked true. Cheers! Stephen
  20. I would look at this page http://ca.php.net/readdir to help you out. I'm a newb  but by looking at the sample code on that page I would think it would look something like this $handle = opendir('/path/to/files') // loop over the directory.   while (false !== ($file = readdir($handle))) {       $file_array[].=$file   } I think this would make an array of everything in the  selected directory. Then all you would have to do it use the count function on the array $file_num = count($file_array). I think that would give you the number you are looking for. Cheers! Stephen
  21. I am passing some values from page to page using checkboxes. I have four different names for the checkboxes and each form an array. What I have been doing so far is putting them into one mutil array and storing it into a session. I was wondering if it would be better to use the one session with mutil array or should I make four session, one for each array being passed. Thanks for you time in this for me. Stephen
  22. Hello all! Ok I have an a form the passes a bunch of checkboxes. E.G. <INPUT TYPE='checkbox' NAME='five[]' value=".$image[$i]."'> This give me the result I want when I look at the code in the page, example would be. <INPUT TYPE='checkbox' NAME='eight[]' value=wedding106.jpg'> Ok I have some checkboxes name five[] as well and I load them into a multi array and jam that into a session. The problem is it seems to be adding a "\" at the end of the value. Does anybody know why this is doing that and maybe  how I can fix it? Not sure if I explained this right, I'm very tired :( hehe.. Let's say I'm using a normal array so when I submit the form $_POST['eight'] will receive all the values of those checkboxes. So it should look like this array('wedding106.jpg') but I'm getting array('wedding106.jpg\') Not sure where the "\" is coming from. Thanks for helping me in this matter :) Stephen
  23. Thanks your code helped me to find out what my problem was. I was not doing testing for the next link, I should have thought of it before hand. All I had to do is see if array[$i] had no value if it didn't then show only the previous link. Again thanks for the help and I hope I can be of some help to some of you someday. Stpehen
  24. I have images stored in a directory that I want to display. I wrote the script that will make a array of the image names. The problem I am having is paging through the array to show 10 images at a time. I have wrote some code that works but the main problem is when the "Next" link gets to the end of the array. It just shows blank spots where images should be (blank image HTML tag) and it goes on forever. ---- Code (No laughter please :( ) -- //count the number of picture in the array $num_pic = count($image); //Set number of pictures to show per page $display_num = 10; //Get current page value if ($_GET['page'] != 0) { $page_num = $_GET['page']; }else{ //Default start page $page_num = 0; } //Get the start number for the array looping $start_pic = $page_num * 10; //Get the end number for array looping $end_pic = $start_pic + 10; //Set row count for table $row_count = 0; echo"<TABLE border ='1'><TR>\r"; for ($i = $start_pic; $i<$end_pic;$i++) { //Check row_count to see if there should be a new table row made or and col. if ($row_count < 3) { echo"<TD valign=\"top\"><img src=\"photos/bethchris/".$image[$i]."\" alt=\"\">"; echo"<br><INPUT TYPE=\"checkbox\" NAME=\"".$image[$i]."\"><div class=\"title\">Check to order</div> </TD>\r"; //Increment row_count by 1 $row_count++;   }else{     echo"<TD valign=\"top\"><img src=\"photos/bethchris/".$image[$i]."\" alt=\"\">"; echo"<br><INPUT TYPE=\"checkbox\" NAME=\"".$image[$i]."\"><div class=\"title\">Check to order</div> </TD>\r"; echo"</TR><tr>\r";     //Re-set the row_count to start new col. $row_count = 0;   } }   if ($page_num == 0) {   //On first page so there is not previous link needed   //Set value for next page.   $next_page = $page_num +1;   echo"<tr><td colspan='4'><a href='display.php?page=".$next_page."'>Next</a><p></td></tr>\r";   }else{   //Fine out what page we are on and create the proper Next and Previous links   $pre_page = $page_num - 1;   $next_page = $page_num +1;   echo "<tr>/r<td colspan='4' align='center'><a href='display.php?page=".$pre_page."'>Previous &nbsp;&nbsp;&nbsp;</a><a href='display.php?page=".$next_page."'>Next</a><p><input type=\"submit\" value=\"Order Photos\" id=\"submit\"></td>\r</tr>";   }   echo "</TABLE>";  ?> Any help would be great, I have been searching for array paging but I only get the MySQL paging results one. I guess I need to figure out how to stop loop once it run to the end. maybe an if statment using isset(array) or something like that. Thank you for you time in this for me Stephen
  25. Thanks for the help that should do the trick. Cheers! Stephen
×
×
  • 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.