Jump to content

Canman2005

Members
  • Posts

    669
  • Joined

  • Last visited

    Never

Everything posted by Canman2005

  1. Hi all I have a simple script which produces a code for me on the homepage, the php I use is [code]srand(time()); $rand1 = (rand()%99999); $rand2 = chr(rand(ord("a"), ord("z"))); $date = date("dmY"); $code = "$rand1$rand2$date";[/code] I then print the code using [code]<?php print "$code"; ?>[/code] How can I retain this code and print it on any page that the user goes to? Even if they return to the homepage, how can I keep the code without it being replaced with a new one? How could I also create a page to delete the code so the user can get a new code when they return to the homepage. Any help would be great Thanks in advance everyone Ed
  2. [!--quoteo(post=350049:date=Feb 27 2006, 11:23 PM:name=Canman2005)--][div class=\'quotetop\']QUOTE(Canman2005 @ Feb 27 2006, 11:23 PM) [snapback]350049[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hello thanks for that, it worked great. I have another question about the same form and php page. How could we get the sql statement to return all rows which contain the first 3 numbers of whatever has been selected from the drop down list? So if 1990 is selected from the drop down on the form, it would return all rows which have 199 in the date column, so 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 as they all start with 199 Any help would be great Thanks Dave Hi Date is a int I have put the following but it didnt like it [code]<? session_start(); include ("db.php"); $y3 = substr($_POST['year'], 0, 3); $sql ="SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS UNSIGNED) AND date <= CAST ('".$y3."9' AS UNSIGNED)"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $num = mysql_num_rows($result); ?>[/code] I get the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('2010' AS UNSIGNED) AND date <= CAST ('2019' AS UNSIGNED)' at line 1 Any ideas? Thanks Dave [/quote] Your other idea worked great. thanks. all fixed stay well dave
  3. Hello thanks for that, it worked great. I have another question about the same form and php page. How could we get the sql statement to return all rows which contain the first 3 numbers of whatever has been selected from the drop down list? So if 1990 is selected from the drop down on the form, it would return all rows which have 199 in the date column, so 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 as they all start with 199 Any help would be great Thanks Dave [!--quoteo(post=350035:date=Feb 27 2006, 10:49 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 27 2006, 10:49 PM) [snapback]350035[/snapback][/div][div class=\'quotemain\'][!--quotec--] The best answer depends on what TYPE you've set date to. $y3 = substr($_POST['date'], 0, 3); If it's a string type: "SELECT * FROM dates WHERE date LIKE '".$y3."%'" If it's an int type "SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS UNSIGNED) AND date <= CAST ('".$y3."9' AS UNSIGNED)" If it's a date type "SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS DATE) AND date <= CAST ('".$y3."9' AS DATE)" [/quote] Hi Date is a int I have put the following but it didnt like it [code]<? session_start(); include ("db.php"); $y3 = substr($_POST['year'], 0, 3); $sql ="SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS UNSIGNED) AND date <= CAST ('".$y3."9' AS UNSIGNED)"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $num = mysql_num_rows($result); ?>[/code] I get the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('2010' AS UNSIGNED) AND date <= CAST ('2019' AS UNSIGNED)' at line 1 Any ideas? Thanks Dave
  4. Hi all I am wondering if you could help me, basically I have a html form which passes a value to a php page, the value is a date, such as 2001 or 2003, the form looks like [code]<form id="sqlfind" method="post" action="sqlfind.php"> <select name="date"> <option value="2010">2010</option> <option value="2000">2000</option> <option value="1990">1990</option> </select> <input name="Submit" type="submit" value="Search"></form>[/code] the sql statement I use on the sqlfind.php page to get the results is [code]<? session_start(); include ("db.php"); $sqlresult = "SELECT * FROM dates WHERE date=".$_POST['date']." AND live=1"; $dateresult = @mysql_query($sqlresult,$connection) or die(mysql_error()); $num = mysql_num_rows($dateresult ); ?> [/code] At the moment is brings results back for only rows which match the date, so if you select the year 1990 it will only find rows which contain 1990. How could I get it to bring back the rows which contain the first 3 numbers of the year, if 1990 is selected it would look for 199 and if 2000 is selected it would look for 200. For example, if you select 1990 from the drop down list on the form then the sql will return 1990 and also 1991 1992 1993 1994 1995 and so on. And if I selected 2000 from the drop down list on the form then it would bring back 2001 2002 2003 2004 2005. Any help would be great. Thanks in advance Dave
  5. Hi all Does anyone know of a very simple php shopping cart script? All I need to be able to do is add multiple items and also remove items. Any help would be great. Thanks in advance Ed
×
×
  • 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.