Jump to content

AE117

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Everything posted by AE117

  1. What I am trying to do is take any number that is 3 chars in length and replace it with 400. I think you are suppose to use str_replace but I can seem to find the right way of doing what i want it to do. Can anyone help me out?
  2. Kinda what I thought. I dont use jQuery though but ill move this to a ajax forum. Thanks
  3. I have a button that when clicked I want it to run a php file. I dont want it to refresh the page i dont want it to open it in a new window I just want to run it, is there a way to do this thanks. Im good at php just really suck with javascript
  4. Aha that's great I need to stop drinking will coding. I appreciate it.
  5. It looks like you are replacing all the / with % $http = "THE Url You want to rewrite"; $rewrite_http = str_replace("/", "%", "$http"); echo $rewrite;
  6. The title makes it sound easy but here is what I am trying to accomplish. I have a form where there is a text feild with the name="name[]" Now I setup a simple foreach foreach ($_POST[name] as $value) { code to ex } Now this works as it gives me the value of the field. I ran into a wall trying to pull not only the value of the field but the id as well. So now lets say the field is as name="name[]" id ="Dynamic from PHP" value = "Dymnamic from php" With a, foreach, is it possible to get both the value as well as the id value? Thanks
  7. Yes it is I thought there was a topic solved button on this forum but I can seem to locate it. I have been staring at my monitors for far too long.
  8. Yes that was to my understanding and apparently there are creative ways to get around such a deli ma.
  9. I seem to be making a habit of solving my own problems but I do hope that everyone else that comes across my problems can find it here the easy way instead of my way. to implode and array to show the keys only function implode_with_key($assoc,$inglue='>',$outglue=', '){ $return=''; foreach($assoc as $tk=>$tv){ $return.=$outglue.$tk; } return substr($return,strlen($outglue)); } nothing in side that needs to be changed. to echo <?php echo implode_with_key($yourarray); ?>
  10. implode(', ', $value); with that function in php is there a way to have it show the key instead of the value. I havnt found anything about that and I am wondering if anyone else has. I have an array and in the array I can echo the key and then the value, the reason I put the implode is becuase it will show it as such 1, 2, 3, 4 etc but I want the keys not the values to show.
  11. Once again I have answered my own question. I dont ever seem to get a reply here. But for anyone else that wants to know here you are. To make the foreach (which is an array) echo into a format the sql can use you will need to take the array. In my case $zips and then do this $valuesz = implode(', ', $zips); echo $valuesz; then You can use the valuesz in the mysql statment valuesz will echo out value, value, value of course the values are what ever information you have in the database or whatever.
  12. It doesnt look like it is getting to that part of the code since it is located in an else statement. Apparently the first statment is getting set as true which is not allowing the else statement to run.
  13. What I have is some PHP that does a foreach statment to find all zip codes in a certain distance. Heres what I need help with. I know the mySQL can use WHERE kkk IN (1,2,3,) how ever how do I tell the php to format the foreach statment in a way that the SQL can use it??? Thanks $zips = $z->get_zips_in_range('00501', 2, _ZIPS_SORT_BY_DISTANCE_ASC, true); if ($zips === false) echo 'Error: '.$z->last_error; else { foreach ($zips as $key => $value) { echo "Zip code <b>$key</b> is <b>$value</b> miles away from <b>97214</b>.<br />"; } echo "<br /><i>get_zips_in_range() executed in <b>".$z->last_time."</b> seconds.</i><br />"; }
  14. Apperantly I am a retard and did not notice that i didnt use "" around auto. So there you have it the code to change a div height to auto is as follows <script language="javascript"> function changeheight(){ e=document.getElementById("commentdiv"); if (e.style.height = 150) {e.style.height = "auto"; }} </script> Please remeber to change the div id to your id, I hope this helps someone
  15. Is there a way to set the height to auto instead of a fixed value? I have this so far <script language="javascript"> function changeheight(){ e=document.getElementById("commentdiv"); if (e.style.height = 150) {e.style.height = auto; } else {e.style.height = 30 + 'px';}} </script> but it only works if i set it like so <script language="javascript"> function changeheight(){ e=document.getElementById("commentdiv"); if (e.style.height = 150) {e.style.height = 350 + 'px'; } else {e.style.height = 30 + 'px';}} </script> 350 being the set value is there a way to make this auto thanks.
  16. O yes make it flow into an Array now why didnt I think of that must be staring at the code for to long. I do appreciate the help Thanks
  17. because there is a code I wrote that starts only at 1 because it can not see 0 as a real integer so it will ignore it. Hence everything that it sees starts at one and any code that interacts with this particular set also needs to start at 1. Yes I know, but the other code only works if it starts at 1. I cant even think of a work around for it if starting at 1 isnt a possibility....
  18. Yes so instead of the results show as 0 = result 1 1 = result 2 i want it to show 1 = result 1 2 = result 2 I really dont even know if this is possible the more I look into it
  19. So as everyone knows when you make a Query Select From Where etc.. the results pull in a list as such 0 - result 1 1 - result 2 ect... Is there a way to make the results start at 1?? And no this is not a problem with Auto Increament in a Table. I need the actually query to start at 1. Thank You
  20. Seems to be working Thank you
  21. Here is what I am trying to do I have an inbox that has a user_sender_id column. This is the column that is being grouped by. SO if you have 5 messages from the same user they all don't so. You just see that you have received a message. So you have multiplie users sending you info. What I need is to arragne this data so the User that sent you the newest message is on top. I have tried this "SELECT * FROM messages WHERE (receiver_user_id=".escape($user_id).") AND (deleted_by_receiver = 0 OR deleted_by_sender = 0) GROUP BY sender_user_id ORDER BY stro ASC"; However since it is grouped the message that is being ORDER BY is the first so the lowest value - --- I have read many things and Came to this "SELECT s1.sender_user_id, message_id, receiver_user_id, timestamp, message, status, deleted_by_receiver, deleted_by_sender, s1.stro FROM messages s1 (SELECT sender_user_id, MAX(stro) AS stro FROM messages GROUP BY sender_user_id) AS s2 ON s1.sender_user_id = s2.sender_user_id AND s1.stro = s2.stro"; But this does not work either. I need to display the lastest record From a Group BY Can anyone help?? THANKS
  22. Ok so here is what I want to do, I have no code I have no idea where to begin. Lets Say I want to watch a program and I want to know how long I have been watching it. SO let their be the field Watching For: Now I dont want to go into my database and change the number of days everyday, is there a way that php can add one for everyday that the item is in the database? Thanks
  23. I hope im posting this in the right section but heres what I want to happen. I have javascript that is used for a drag and drop feature however for every item you want to drop you have to add the code in manually. Is it possible for the javasript to build an array off of a certain class of div tags ? Here is the code <script type="text/javascript"> // Custom drop actions for <div id="dropBox"> function dropItems(idOfDraggedItem,targetId,x,y) { var html = document.getElementById('textarea').innerHTML; if(html.length>0)html = html + '<br>'; html = html + 'Item with id="' + idOfDraggedItem+'" dropped'; document.getElementById('textarea').innerHTML = html; } // Custom drop actions for <div id="dropBox2"> function dropItems2(idOfDraggedItem,targetId,x,y) { var html = document.getElementById('dropContent2').innerHTML; if(html.length>0)html = html + '<br>'; html = html + 'Item "' + document.getElementById(idOfDraggedItem).innerHTML + '" dropped'; document.getElementById('dropContent2').innerHTML = html; } var dragDropObj = new DHTMLgoodies_dragDrop(); [color=red]dragDropObj.addSource('box1',true);[/color] // Make <div id="box1"> dragable. slide item back into original position after drop dragDropObj.addSource('box3',true); // Make <div id="box3"> dragable. slide item back into original position after drop dragDropObj.addSource('box4',true); dragDropObj.addSource('box5',true); // Make <div id="box4"> dragable. slide item back into original position after drop dragDropObj.addTarget('dropBox','dropItems'); // Set <div id="dropBox"> as a drop target. Call function dropItems on drop dragDropObj.addTarget('dropBox2','dropItems2'); // Set <div id="dropBox2"> as a drop target. Call function dropItems2 on drop dragDropObj.init(); </script> the part that would be the array is the var dragdrop the elements under it dragDropObj.addsource('box#', true); I dont even know if this is possible so let me know Im not good with javascript Thanks
  24. Heres what I want to do I want to see if the field is blank Which I have just fine. What I want it to do is check the field and then change the color of that field if it is blank. Heres what I have <link href="style.css" rel="stylesheet" type="text/css"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="login_form" id="login_form"> <p> <label>UserName <input type="text" name="user_name" id="user_name"> </label> </p> <p> <label>Enter Your Password <input type="password" name="user_password" id="user_password"> </label> </p> <p> <input type="submit" name="submit" id="submit" value="Enter"> </p> </form> <p> <?php require_once ('connect.php'); if(!$dbconnect = mysql_connect($host, $user, $pass)) { echo "Connection failed to the host 'localhost'."; exit; } if (!mysql_select_db($database)) { echo "Cannot connect to database"; exit; } foreach($_POST as $value) { if ($value == "") { echo "Please enter you Information"; echo "<input name='user_name' class='error' id='user_name'>"; } } ?> the class that i have for the css style is .error thanks
  25. I almost got it and then my damn server failed but this will get you way start Pretty much it only checks to see if the first name is filled in not first and last <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"> <html> <head> <title></title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> First name: <input type="text" name="first_name"><br> Last name: <input type="text" name="last_name" style="position: relative; left: 1px;"> <input type="submit" value="Submit"> </form> <?php $first = @$_POST['first_name']; $last = @$_POST['last_name']; $charecter = array("is gay", "is cool", "is a funny", "is a wierdo", "is just dumb"); $doing = array("farts alot", "runs in circles", "...", "and loves strawberry shortcake"); $number = range('0','9'); $test = ($number[rand(0,9)]) . ($number[rand(0,9)]); if(empty($first)) echo "Please Enter Your First and Last Name"; elseif($first=$first) echo $first . " " . $last . " " . $charecter[rand(0,4)] . " and " . $doing[rand(0,3)] . "<br /> Lucky Number: " . $test . "."; elseif($test < 99 && $test > 50) echo "That is a great number!"; ?> </body> </html>
×
×
  • 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.