Jump to content

gladiator83x

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by gladiator83x

  1. Hi All, I have a variable named $title that holds a title. I also have a table with a column full of titles. I am trying to compare that variable to each cell inside the column of titles, and if there is no match, I wanted to append it to the end only once. However, I am a little stuck because everytime there is no match that variable is appended many times because it is in the loop. Is there any way that I can exit this loop as soon as I do not find a match and append it on only once? This is my code:             for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); if ($row[topic_title]!= $title){ echo $test_date; mysql_query("INSERT INTO End_Review (id,topic_title, date) VALUES('','$title','$test_date' ) ") or die(mysql_error());}             }
  2. Hi All, I was just wondering if anyone could help me troubleshoot this error that I keep receiving. I am trying to delete something in a table if it is  already in there, and I keep receiving an error message that states that something is wrong with my syntax. I changed it around several times, but still nothing. Any suggestions? $res=mysql_query("select * from End_Review"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; if (mysql_num_rows($res)!=0) { for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); } // $row is an array of titles mysql_query("DELETE FROM End_Review WHERE $title==$row[topic_title]") or die(mysql_error()); } If it helps, this is how I input data into this table--it works fine. mysql_query("INSERT INTO End_Review (id,topic_title, date) VALUES('','$title','$test_date' ) ") or die(mysql_error());
  3. [!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--] Hey All, I have a Mysql table (called End_Review) and it has 3 columns: an incrementing number, topic_title, and date. On another page I have have a listbox with many topic names. When a topic is chosen, I go to another page where this topic name is passed as $title. Each time I choose a new topic name, I want it to be stored in a database. If it is already in the database, I just want an output message that says that it has already been stored. [!--colorc--][/span][!--/colorc--] $res=mysql_query("select * from End_Review"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else { if ($title !=$row[topic_title]){ mysql_query("INSERT INTO End_Review (id,topic_title, date) VALUES('','$title','$test_date' ) ") or die(mysql_error()); } else{ $end_query= "SELECT End_Review.date FROM End_Review WHERE End_Review.topic_title='$title'"; $end_result = mysql_query($end_query) or die('Query failed: ' . mysql_error()); $line = mysql_fetch_array($end_result, MYSQL_ASSOC); foreach ($line as $col_value) { echo "\t\t<td>$col_value3</td>\n"; } exit("This topic has already been reviewed. Please observe the timestamp"); }}} [!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--]All this code pretty much does is compare the specified title with the titles from the table and if it finds a match the associated data will be retrieved. However, my problem is whenever the specified data is not match, it keeps on populating my table with the same data. I know that it should be in the for loop, but I am confused as to where it could go? Any suggestions?[!--colorc--][/span][!--/colorc--]
  4. [!--quoteo(post=385217:date=Jun 17 2006, 10:49 PM:name=gladiator83x)--][div class=\'quotetop\']QUOTE(gladiator83x @ Jun 17 2006, 10:49 PM) [snapback]385217[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi Robos99, I believe that it is definitely a Unix Timestamp. Check out the link: [a href=\"http://en.wikipedia.org/wiki/Unix_epoch\" target=\"_blank\"]http://en.wikipedia.org/wiki/Unix_epoch[/a] [/quote] The code that Fyorl definitely looks correct, and I know that I am connecting to the database but I keep getting the following error: Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /export/home2/webpages/confirm.php on line 86 I changed it up a couple of times, and still nothing. Anybody else ever get this error message, and if so...what did you do to fix it?
  5. [!--quoteo(post=385208:date=Jun 17 2006, 10:33 PM:name=robos99)--][div class=\'quotetop\']QUOTE(robos99 @ Jun 17 2006, 10:33 PM) [snapback]385208[/snapback][/div][div class=\'quotemain\'][!--quotec--] Maybe I'm nitpicking here but isn't 2006-06-17 09:50:37 not a Unix timestamp? I may be wrong though. [/quote] Hi Robos99, I believe that it is definitely a Unix Timestamp. Check out the link: [a href=\"http://en.wikipedia.org/wiki/Unix_epoch\" target=\"_blank\"]http://en.wikipedia.org/wiki/Unix_epoch[/a]
  6. [!--quoteo(post=384976:date=Jun 17 2006, 10:33 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 17 2006, 10:33 AM) [snapback]384976[/snapback][/div][div class=\'quotemain\'][!--quotec--] You can use MySQL's DATEDIFF function: [a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/dat...-functions.html[/a] As for doing that with PHP, check the user notes here: [a href=\"http://www.php.net/mktime\" target=\"_blank\"]http://www.php.net/mktime[/a] [/quote] I am having a problem using the DATEDIFF function. This is what I am typing in: $diff= SELECT DATEDIFF($test_date,$creation_ts); echo $diff; This is the output that I receive: SELECT DATEDIFF(2006-06-17 21:24:48,2004-08-09 11:01:24) It doesn't subtract the dates. When I typed in the same thing minus the SELECT, it didnt recognize the DATEDIFF function. $diff= DATEDIFF($test_date,$creation_ts); echo $diff; Anyone have any suggestions???
  7. Hey All, I tried asking this question yesterday, but the feedback that I received did not really answer my question. I just wanted to know if there was a way to take the difference between two Unix time stamps in php; with both of them in the form of: 2006-06-17 09:50:37?
  8. Hey Tec_Matt, I'll give it a shot. Thanks.
  9. Hey All, I had inserted timestamps in several of my MYSQL tables. One time stamp represents the time that something was created, the other represents the time that that same something was finished and submitted. I was trying to figure out if there was some sort of math function that will take the difference of these two timestamps? The piece of code below shows how I am obtaining my timestamps; I then just echo the variable I equate the date function to. $test_date = date("Y-m-d H:i:s"); If any of you could help me out on this one, that would be awesome [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  10. Hey All, I was just wondering if there was any way that I can terminate my code in php? Is there some sort of break command that will stop the compiler from executing the rest of the code? This is a tidbit of my code: -------------------------------------------------------------------------------------------------------- $res=mysql_query("select * from End_Review"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else{ for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); // echo $row[topic_title]; } if ($title==$row[topic_title]) echo '<FONT COLOR=<"FF0000">"A closing time stamp already exists for this topic. Please observe the cycle.</FONT> '; } [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]mysql_query("INSERT INTO End_Review (id,topic_title, date) VALUES('','$title','$test_date' ) ") or die(mysql_error());[!--colorc--][/span][!--/colorc--] //} ------------------------------------------------------------------------------------------------------- I just wanted the code to basically stop if ($title==$row[topic_title]) and not go into the red mysql query section. Could someone please help me? [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  11. Hey All, I was just trying to combine these two links below (Which work perfectly fine on their own). ------------------------------------------------------------------------------------------- <?php //link 1 echo "<a href=\"confirm.php?string11=$hlink\">Click this link to close the review and end the cycle.</a>"; //link 2 echo '<form method="post" action="confirm2.php"> Date of Review Closure : <input type="text" name="phone_number" /><br><br><br /><input type="submit" name="submit" value="submit" /> </form>'; ?> ------------------------------------------------------------------------------------------- I was trying to include the hyperlink into the action portion of the form. My goal is to have $hlink and “phone_number” defined on the same page (file). This is what I have tried: <? echo '<form method="post" action=" confirm.php?string11=$hlink "> Date of Review Closure : <input type="text" name="phone_number" /><br><br><br /><input type="submit" name="submit" value="submit" /> </form>'; ?> but I all I receive is the word $hlink instead of what it holds.
  12. [!--quoteo(post=383455:date=Jun 13 2006, 04:25 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 04:25 PM) [snapback]383455[/snapback][/div][div class=\'quotemain\'][!--quotec--] echo "<a href=\"page2.php?string11=$hlink\">String is:</a>"; [/quote] Thanks Joquius!!! That definitely worked [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  13. Hey All, I have two pages and I am trying to pass a variable called $hlink from page1.php to page2.php. I was just wondering if someone could help me out? This is what I have been using: On page1.php: <php echo '<a href="page2.php?string11= . $hlink . ">String is:</a>'; ?> <?php On page 2 I have : if (isset ($_GET['string11'])) echo $_GET['string11']; ?> My variable $hlink stores a title that I want to bring up again on page2.php; however, the only thing that pops up is the output ".$hlink." Any suggestions?
  14. [!--quoteo(post=383413:date=Jun 13 2006, 02:40 PM:name=gladiator83x)--][div class=\'quotetop\']QUOTE(gladiator83x @ Jun 13 2006, 02:40 PM) [snapback]383413[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thanks Ober!!! You're the Man [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] [/quote] Actually, that did not quite work right. All my code was already in php brackets. I am just echoing the html code. So the code below won't work either, It is what I already have. <a href="file_2.php?string=<?=$hlink?>">String is 3</a> A snippet of my code is : <php // just the last several lines of my code echo '<a href=review_end1.php?string11=$hlink>String is 3</a>'; // this also has the same output as echo '<a href="review_end1.php?string11=$hlink">String is 3</a>'; // Free resultset mysql_free_result($result); // Closing connection mysql_close($link); ?> The double quotes did not matter. I am still returning "$hlink", instead of what $hlink holds. Any other suggestions?
  15. [!--quoteo(post=383411:date=Jun 13 2006, 02:33 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Jun 13 2006, 02:33 PM) [snapback]383411[/snapback][/div][div class=\'quotemain\'][!--quotec--] <a href=file_2.php?string=$hlink>String is 3</a> You're not using quotes around the href, PLUS $hlink is a php variable.... you need to put it inside PHP tags: <a href="file_2.php?string=<?=$hlink?>">String is 3</a> [/quote] Thanks Ober!!! You're the Man [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  16. [!--quoteo(post=383319:date=Jun 13 2006, 11:32 AM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 11:32 AM) [snapback]383319[/snapback][/div][div class=\'quotemain\'][!--quotec--] you mean page.php?string=value ? this is <a href="?string=3">String is 3</a> <? if (isset ($_GET['string'])) echo $_GET['string']; // 3 ?> you can do this on the same page, different pages, etc [/quote] Thanks Joquius, that helped me out big time. I was trying to switch it around a little bit though and I couldn't get this to work: <a href=file_2.php?string=$hlink>String is 3</a> <a href="?string=">String is 3</a> <? if (isset ($_GET['string'])) echo $_GET['string']; // 3 ?> $hlink is my variable name and I am trying to return what it is on another page; however, all I am returning is the word $hlink. Any suggestions? I am stumped.
  17. Hi All, I was just wondering if anyone could explain to me how to pass a variable from one file to another. I know that when there is a form involved, one can use: $variable_new = $_REQUEST['passed_variable] ; This works just fine, but I wanted to know if there were any other ways to pass variables to other files? Christopher [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]
  18. [!--quoteo(post=382836:date=Jun 12 2006, 10:21 AM:name=scripts2go.co.uk)--][div class=\'quotetop\']QUOTE(scripts2go.co.uk @ Jun 12 2006, 10:21 AM) [snapback]382836[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think the easiest way of doing this would be to use cookies and make the page check for your assosiated data before loading the page. If your users are logging in to your website with a mysql backend you could create a table and store all of the saved data for page and user in a database and recall that information everytime your page loads. [/quote] Thanx Scripts2go ; ) I'll definitely try that!
  19. Hey All, I have a listbox that is comprised of about 50 options. When one option is selected it takes the browser to a page where associated data is automatically generated from a database. What I am trying to do is put a textbox of some sort on the second page and when data is inputted, I wanted it to be saved for each particular option in the list box. So if I chose lets say option A, and the associated data pops up along with a text box, I want to be able to enter in the word ‘dog’. When I open up another browser and select option A again, I would like to see besides my associated data, a select command that will take me to the page that has dog saved. Is that caching? I would really appreciate it if you any one of could help me. Thanks [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Christopher
  20. Hi All, I was wondering if anyone could help me out with a problem that I have run into. Lets say there are only two things on a page (lets call this page testa.php). The two items are a text box and a submit button. When the person browsing inputs data into the text box and pushes submit, it goes to page (testb.php) and the data inputted in the text box is displayed on this page. I was able to do all of this, however, I want the data that is inputted in the text box to not just be submitted to the next page, but also saved on that page; so if anyone was to go back to testb.php, he/she would be able to see the data that was entered in that text box. How would the form look? I have been reading different things online, looking at code on frontpage, and looking through a book that I purchased, but I cannot find out how to submit & save. If anyone could point me in the right direction or help me start off the code then that would be awesome. Thanks. --Chris
×
×
  • 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.