Jump to content

mpharo

Members
  • Posts

    221
  • Joined

  • Last visited

    Never

Everything posted by mpharo

  1. What is the error your getting? Just looking at your code, you do not set $value up as anything...I dont know if your passing it from another page or what, but $value is not set as variable, so essentially your cookie has no data..
  2. phpmyadmin is an awesome tool for SQL management, when you click on the table it brings up the table stucture page, in about the middle of the window on the left hand side it says indexes, from here you can see what fields are indexed on or are set as unique, if you have it set as unique you wont be able to have id's listed more than once, so just change it so it is indexed but not uniquly, with the button that looks like a lightning bolt at the end of that field..now in your inserts you can keep your original insert but just add an additional one to insert the same thing into the different table, unless it is in a different database...I can post the code if you need further assistance..
  3. $_SESSION['fName'] = $first_name; $_SESSION['lName'] = $last_name; used to create the sessions.... echo $_SESSION[ 'first_name'] . " " . $_SESSION['last_name'], " used to display the sessions... theyre different variables...
  4. mispelled columns in the second for statement
  5. what database are you using? you can just try inserting a duplicate entry for all fields and see what happens, but you should have some sort of admin tool that you can use to view you table structure...
  6. Well to use it as a session you would do this... session_start(); $_SESSION['productId']=$productId; Then on the next page you would just add a session_start(); and use the variable name $_SESSION['productId'] to get the value...
  7. Or you can use the above code with a POST instead of a GET...would probably be easier...
  8. Which line specifically are you getting a result from where they are not equal? or lines??
  9. You can then use the variable as $_GET['productId'] in the second page
  10. Just do another insert statement, but remove the unique index on the emp_id field if you have one and just make it a normal index...
  11. What I do is execute the query, then use the mysql_num_rows function to get the total results...I then start at 0 then increment by 50 until I hit the total.... If(!$_POST['start']){ $start=0; }Else{ $start=$_POST['start']+50; } $select = mysql_query("SELECT * FROM table WHERE field='test' LIMIT $start, 50") or die(mysql_error()); $totalRows=mysql_num_rows($select); while($sql=mysql_fetch_array($select)) { } You just then need to create a simple form for each previous and next which has a hidden value called start and then submit the form to itself, for previous you just subtract 50, there is some fault tolerence you need to put into place as well like, if it is less than 0 or greater than $totalRows....like I said this will get you started but it is not complete code...
  12. Just add the full url to your file...such as www.phpfreaks.com before the page your calling... include('http://www.phpfreaks.com/cart.php?action=view');
  13. $_SESSION['username'] = $usename; spelled username wrong
  14. Well it wont work because your saying if it is equal to null, not not initialized...try doing this... If (!$_POST['date'] or $_POST['date'] == "") { Echo "Date empty..."; }
  15. how is $_POST['date'] being populated....you must be getting it from another form.....in your error handle you have If ($_POST['date'] == "") which means if it is intialized but it is empty { Do This } so how is it getting populated?
  16. Best way is probably the GROUP BY clause in your SELECT statement, you would just do SELECT * FROM table GROUP BY field ASC or something along that lines...
  17. You need to loop through the information with a while loop...something like this <? mysql_select_db($database_BFsite, $BFsite); $query_news = "SELECT * FROM News ORDER BY showORDER ASC"; $query_limit_news = sprintf("%s LIMIT %d, %d", $query_news, $startRow_news, $maxRows_news); $news = mysql_query($query_limit_news, $BFsite) or die(mysql_error()); while($row_news = mysql_fetch_assoc($news)) { ?> <a href="newsDetails.php?ID=<?php echo $row_news['ID']; ?>"> <? } ?>
  18. You just need to create a simple form with a username and password field, then pass these 2 fields into a page that you will use to execute your sql query from to compare the username and password submitted to...it will look something like this.... index.php <form name="login" method="post" action="auth.php"> <table border="1"> <tr> <td> Enter Login: </td> <td> <input type="text" name="username"> </td> </tr> <tr> <td> Enter Password: </td> <td> <input type="password" name="pass"> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Login"> </td> </tr> </table> </form> auth.php $password=md5($_POST[pass]); $select=mysql_query("SELECT * FROM users WHERE username=$_POST[username] AND password=$password") or die(mysql_error()); $sql=mysql_num_rows($select); If ($sql){ echo "Login Sucessfully!"; }Else{ echo "Login Failed!!"; } You just need to have a table called users with a field called username and a password field with md5 encryption...
  19. $queryFirst = " SELECT MIN(actionID), name, subjectID, subject, timestamp FROM onetable GROUP by subjectID ORDER by timestamp DESC "; You are ordering DESC which is last result first...I think you are trying to do too much in a single query with the results...try breaking it up into 2 queries...one to get the first/last result and another to get the data for that result....like this... $queryFirst=mysql_query("SELECT MIN(actionID) , subjectID FROM onetable GROUP BY subjectID"); while($sqlFirst=mysql_fetch_array($queryFirst)) { $queryFirstData=mysql_query("SELECT actionID, name, subjectID, subject, timestamp FROM onetable WHERE actionID='$sqlFirst[actionID]' AND subjectID='$sqlFirst[subjectID]'"); $sqlFirstData=mysql_fetch_array($queryFirstData); echo "FIRST DATA"; echo "actionID: " . $sqlFirstData[actionID] . "subjectID: " . $sqlFirstData[actionID] . "subject: " . $sqlFirstData[subject] . "timestamp: " . $sqlFirstData[timestamp]; } $queryLast="SELECT MAX(actionID) , subjectID FROM onetable GROUP BY subjectID"; while($sqlLast=mysql_fetch_array($queryLast)) { $queryLastData=mysql_query("SELECT actionID, name, subjectID, subject, timestamp FROM onetable WHERE actionID='$sqlLast[actionID]' AND subjectID='$sqlLast[subjectID]'"); $sqlLastData=mysql_fetch_array($queryLastData); echo "LAST DATA"; echo "actionID: " . $sqlLastData[actionID] . "subjectID: " . $sqlLastData[actionID] . "subject: " . $sqlLastData[subject] . "timestamp: " . $sqlLastData[timestamp]; } Changed the code, I relaized in the min/max the () are in wrong spot
  20. In this case you need to pass in the subjectID for the last reply you wanna get, im not sure if this is a main page or a refering page but this is somewhat what it should look like.... //Coming from one page or another depends on how this gets populated, if it is the same page it can be done like this but if it is from a refering page you need to either use a $_GET or $_POST to populate it $var=$subjectID; $queryLastReply = " SELECT MAX(actionID), name, subjectID, subject, timestamp FROM onetable WHERE subjectID='$var' GROUP by subjectID "; this is untested but it should work properly, otherwise you can simplify this greater by doing something like this: $var=$subjectID; $queryLastReply = " SELECT actionID, name, subjectID, subject, timestamp FROM onetable WHERE subjectID='$var' ORDER BY actionID DESC "; this will order it by actionID and then sort it by the last result first, you can then do a single mysql_fetch_array() outside of a loop to get the single result...
  21. Are you trying to display the last reply for all subjects or just a single subject?
  22. Then this function will do that, you will just need to feed it the results one by one with a loop...
×
×
  • 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.