im sorry, but what exactly do you mean
Nnotaloser
- Oct 9, 2006
- Joined Mar 29, 2003
it seems like you should be updating your date1 field each time that it expires rather than adding another useless field every time your record ends.. which gets complicated and really wouldnt work.
if you would explain your system a little more and explain everything you are trying to do, we could get some code written
im sorry but it is unclear what you are asking here.. i'm sure we can help you if you refine your question
go ahead and post what you have written so we can help you
<? $query="select id, user, url, status from links where status='1'"; $result = mysql_query($query) or die( "ERROR: " . mysql_error() . "n");
while ($myrow = mysql_fetch_array($result)) {
$id=$myrow["id"]; $url=$myrow["url"]; $query2 = "select fields from linkhits where linkid = '$id'"; $result2= mysql_query($query2) or die( "ERROR: " . mysql_error() . "n"); $num = mysql_num_rows($result2); if(empty($num)) { // there are no rows for this id, it hasnt been clicked $color = "black"; // make it black }else{ $color = "blue"; // make it blue if it HAS BEEN clicked } echo "<font color='".$color."'>"; ?> <a href="linkhits.php?id=<? echo $id;?>&url=<? echo $url;?>&userid=<? echo $userid;?>">link title here</a><br> <? echo "</font>"; } ?>**edit forgot about strtotime, use that
try
<?php ob_start(); session_start(); ...
- In Pagination
$query = "SELECT * FROM test WHERE testid BETWEEN $limitvalue AND $limitnew ORDER BY date ASC";
is that what you mean? you want the newest entries to be displayed first?
when you are displaying the information on your php site, you could:
find the number of days inbetween the posted date and the current date
if the number of days is under 7, then say "this week"
*if the number is over 7, divide it by 7 days in a week to get the approximate number of weeks.
-if the number of weeks is greater than say 6 ("about 6 weeks"), divide the number of weeks by 4 to get the approximate number of months.. and on and on for years and decades etc..make sense?
before you query, explode the string with multiple values into an array, and loop the values through the query
$searchterms = "1, 4"; $pieces = explode(", ", $searchterms); foreach($pieces as $value) { $query = mysql_query("SELECT field FROM table WHERE field = '".$value."' "); $rows = mysql_fetch_row($query); echo $rows[0] // the result of the query }
when i use $_SERVER['REMOTE_ADDR']; i get my IP address..
however, the ip address that you may have been told of by your ISP and the one that requests page information may be different if you use proxy or routers, etc..
your code looks solid, maybe you should try just declaring $id in the URL and setting up your links using $_GET['id'] directly instead of going through your $add +1 or -1.. cant quite see what is wrong with what you have right now sorry
<?php if ($_POST['submit']) { header ("Location: http://www.somedomain.com/web-defect/ViewDefect.cgi?defect=".$_POST['defect_number']."&CMVC_FAMILY=family@family.somedomain.com@80"); } else { ?> <html> <head><title>CMVC Web Interface</title></head> <body> <Table border="1"> <FORM METHOD="post" ACTION="<?php echo $PHP_SELF?>"> <TR> <TD ColSpan=1 RowSpan=1 Align=Center> <INPUT TYPE="text" NAME="defect_number" SIZE=6> </TD> </TR> <TR> <TD ColSpan=1 RowSpan=1 Align=Center> <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> </TD> </TR> </form> </table> <?php } // end if ?> </body> </html>
also, make sure you have output buffering started
$_SERVER['REMOTE_ADDR'];
check out all the predefined $_SERVER variables here
you could:
create a field ordernumber or orderID, not auto-increment, but plan on having an auto-increment LIKE system, where each full order will be 1 more than the last one
then query the largest ID, before inserting, and insert each item ordered by the customer as that ID + 1.. that way, you have a system that creates a new ID for each order as it is placed, groups all the items in 1 order together, and will stop any duplication and mixing up of customers who place multiple seperate ordersmake sense?
and as for checking new orders.. you could have each row have a field "new" or something similar, and update each row from new="yes" to new="no" as you view them on an administration page.
all you need to do is check to see if a row exists for each one, and if not, don't display the link.. can be done using mysql_num_rows
$query = "SELECT field FROM table"; $result = mysql_query($query); $numrows = mysql_num_rows($result); $rowp = mysql_result($result,0); $query2 = "SELECT field FROM table"; $query = "SELECT field FROM table"; $result = mysql_query($query); $numrows2 = mysql_num_rows($result); $rown = mysql_result($result,0); $query2 = "SELECT field FROM table"; echo "<center>"; if(empty($numrows)) { // no rows returned // what to do if no rows returned }else{ ?> <a href="jokecontent.php?id=<? echo "$rowp"; ?>">Previous Joke</a> <?php } if(empty($numrows2)) { // no rows returned again // what to do if no rows returned here }else{ ?> <a href="jokecontent.php?id=<? echo "$rown"; ?>">Next Joke</a> <?php } echo "</center>"; ?>
unfortunately, HTTP_REFERER is not reliable.. ive run into the same problem trying to determine referring pages.. a value is returned only when the user takes an action directly linking them to your page, and i am unsure of any other way..
you could try checking to see if the variable is null, and only enter it if it is not. that way, you can still get some referring pages and not all the blank entries.
thats weird that your book would write it like that..
because if you have echo "<input type='text' name='text1' value='".$_POST[text1]."'> then you are saying display the value of what is POSTED in the box on submition as the value of the textbox on loading the page.. but thats ok, you don't need that part.
any time you work with sessions on any page of your website, you will want to keep session_start();, so in this case, you will need it on both pages.
here you go.. btw.. why do you have your $_POST['var'] as the values of your html? there will be nothing displayed until you press submit, and when you do.. your location will be changed.. in that case, i just took them out
make sure session_start(); is at the first line of your code
///first page ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if ( isset ($_POST['submit'])) { $problem = FALSE; // No problems so far. // Check for each value. if (empty ($_POST['username'])) { $problem = TRUE; print '<p>Please enter a username!</p>'; } if (empty ($_POST['first_name'])) { $problem = TRUE; print '<p>Please enter your first name!</p>'; } if (empty ($_POST['last_name'])) { $problem = TRUE; print '<p>Please enter your last name!</p>'; } if (empty ($_POST['email'])) { $problem = TRUE; print '<p>Please enter your email address!</p>'; } if (empty ($_POST['password1'])) { $problem = TRUE; print '<p>Please enter a password!</p>'; } if ($_POST['password1'] != $_POST['password2']) { $problem = TRUE; print '<p>Your password did not match your confirmed password!</p>'; } if (!$problem) { // If there weren't any problems... $string = $_POST['username'].":".$_POST['first_name'].":".$_POST['last_name'].":".$_POST['email'].":".$_POST['password1']; $_SESSION['registerinfo'] = $string; header("Location: thankyou4.php"); exit(); } else { // Forgot a field. print '<p>Please try again!</p>'; } } // End of handle form IF. print '<div id="leftcontent">'; print "<h4>Register here to access Fred's Forum and to purchase CD's</h4>"; // Display the form. print '<form action="register.php" method="post"><p>'; print 'Username: <input type="text" name="username" size="20" /><br />'; print 'First Name: <input type="text" name="first_name" size="20" /><br /> Last Name: <input type="text" name="last_name" size="20" /><br /> Email Address: <input type="text" name="email" size="20" /><br />'; print 'Password: <input type="password" name="password1" size="20" /><br /> Confirm Password: <input type="password" name="password2" size="20" /><br /> <input type="submit" name="submit" value="Register!" /></p> </form>'; // Complete the HTML formatting stuff. print '</div>';
// and here on thankyou4.php <?php $registerinfo = $_SESSION['registerinfo']; $info = explode(":", $registerinfo); $username = $info[0]; $password = $info[4]; $firstname = $info[1]; $lastname = $info[2]; $email = $info[3]; echo $firstname." ".$lastname."<br/>"; echo "<br/>"; echo "Thank you for your registering.<br/>"; echo"<br/>"; echo "Please make a note of your username <b>".$username."</b> and your password <b>".$password."</b>. You will use these to login for entering comments in the forum, to add an entry to the guestbook, and when you're ready to purchase a CD.<br/>";
you see, your variables $_POST['whatever'] on thankyou4.php are not valid anymore when the header location changes pages
in order to pass the variables, you could move all the form processing code over to thankyou4.php, change a few things in the processing to fit of course, and set your <form action="thankyou4.php">.
OR
you could create a session using the variables posted and kill them after they are displayed on thankyou4.php
with your system, i would just do something like this using explode:
//on your first page.. $string = $var1.":".$var2.":".$var3; $_SESSION['registerinfo'] = $string; header("Location: thankyou4.php");
//and here on thankyou4.php $registerinfo = $_SESSION['registerinfo']; $info = explode(":", $registerinfo); echo $info[0]; //var1 from your prev page echo $info[1]; //var2 from your prev page echo $info[2]; //var3 from your prev page
when submitted and there are no problems, a string with the registration information is created (seperating each one with the character ':') and a session is started with the string.
then the location is changed and you explode the session information into the array $info, and you can echo them out as so..thats probably how i would go about it,
good luck