Jump to content

todayme

Members
  • Posts

    82
  • Joined

  • Last visited

    Never

Everything posted by todayme

  1. I have 2 pages all the code works until I try to do the third item, please help solve this. First Page <? //set IE read from page only not read from cache header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header("content-type: application/x-javascript; charset=tis-620"); $data=$_GET['data']; $val=$_GET['val']; //set database $dbhost = "localhost"; $dbuser = "333"; $dbpass = "333"; $dbname = "333"; mysql_pconnect($dbhost,$dbuser,$dbpass) or die ("Unable to connect to MySQL server"); if ($data=='states') { // first dropdown echo "<select name='states' onChange=\"dochange('cities', this.value)\">\n"; echo "<option value='0'>==== Please Select ====</option>\n"; $result=mysql_db_query($dbname,"select `id`, `state` from states order by `state`"); while(list($id, $name)=mysql_fetch_array($result)){ echo "<option value=\"$id\" >$name</option> \n" ; } } else if ($data=='cities') { // second dropdown echo "<select name='cities' onChange=\"dochange('profile', this.value)\"> \n"; echo "<option value='0'>==== Select Industry ====</option> \n"; $result=mysql_db_query($dbname,"SELECT `id`, `city` FROM cities WHERE `state_id` = '$val' ORDER BY `city` "); while(list($id, $name)=mysql_fetch_array($result)){ echo "<option value=\"$name\" >$name</option> \n" ; } } echo "</select>\n"; ************************************************************************* ************************************************************************ [b]THIS CODE BELOW IS RELATED TO THE OTHER PAGE THIS IS WHERE I AM HAVING A PROBLEM[/b] if ($data=='profile') { $result2=mysql_db_query($dbname,"SELECT `Profile` FROM _Industries WHERE `Industry` = '$name' "); echo "$result2 \n" ; } *************************************************************************** ?> <? echo "<form name=Leads>\n"; echo "<font id=states><select>\n"; echo "<option value='0'>============</option> \n" ; echo "</select></font>\n"; echo "<br>\n"; echo "<br>\n"; echo "<font id=cities name=cities><select> \n"; echo "<option value='0'>=== none ===</option> \n" ; echo "</select></font>\n"; BELOW IS RELATED TO THE FIRST PAGE BETEWEEN THE TWO THERE IS A PROBLEM PLEASE CAN SOMEONE HELP *************************************************************************** *************************************************************************** //echo "<font id=profile>\n"; echo "<div id=profile> </div>\n"; ***************************************************************************** ?> <script language=Javascript> function Inint_AJAX() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript alert("XMLHttpRequest not supported"); return null; }; function dochange(src, val) { var req = Inint_AJAX(); req.onreadystatechange = function () { if (req.readyState==4) { if (req.status==200) { document.getElementById(src).innerHTML=req.responseText; //retuen value } } }; req.open("GET", "state.php?data="+src+"&val="+val); //make connection req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header req.send(null); //send value } window.onLoad=dochange('states', -1); // value in first dropdown </script>
  2. Could someone please show me how to delete records from mysql. Maybe even an example in a loop that deletes records based on a criteria.
  3. Wrong, the information in the database is the same that is outputed. Date(d.m.y) I figure its a server configuration issue. Just so you know it is a problem, I am no f.. wit.
  4. HEY DUDE ITS NOT THE YEAR, UNLESS THE YEAR INCROMENTS EVERY DAY..
  5. Make sure when that the email is sent from someone that is an email that is valid, the way php is setup on my server it sends the email from admin@mydomain.com if you dont have it sent from someone Hotmail will not except it as incoming. It is a configuration on some mail servers.
  6. I dont think it is a code problem but maybe a problem on the server anyone had this problem. Below from the left is the day then the month then the year. Notice how it adds 20 infront of the day. 2014-03-07
  7. Also the the query in the //------------ is to a different table to the first one outside the //--------
  8. See below between //------------ I have written an explination, I have tried and tried to do this can someone please help. ?> <select name="Location"> <?php $query=mysql_query("SELECT $dbState FROM $locationtype"); while ($fetch=mysql_fetch_assoc($query)) { //----------------------------------------------------------------- Select from table where Industry = $dbIndustry and Location1 = $dbState If one or more records exists put the value of the first query into the drop down box if not dont do it //----------------------------------------------------------------- echo '<option value="'.$fetch[$dbState].'">'.$fetch[$dbState].'</option>'; } mysql_close($db);?></select>
  9. Notice below I am trying to say in the code is If ($doit['Status'] == "") if its empty do assign a value. But it never thinks its empty when it is. Is this how you check if it is empty? $query = "select max(ID) from _Replies where LINKID = '$LeadID' AND SenderID = '$findID'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result) or die(mysql_error()); foreach($row as $key => $val) { $data = mysql_query("SELECT * FROM _Replies WHERE ID = '$val'") or die(mysql_error()); $doit = mysql_fetch_array($data); If ($doit['Status'] == "") { $coolstatus = "New Lead"; } else; { $coolstatus = $doit['Status']; }
  10. Note the code below selects the exact row I am looking for but I need to get the value of the field Status Could someone please show me whats going on, The code works well selects the write row but within that row I just need to get the value of the field Status. $query = "select max(ID) from _Replies where LINKID = '$LeadID'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result) or die(mysql_error()); foreach($row as $key => $val) { Print $row['Status']; echo "The highest value is: ".$key." with a value of ".$val; }
  11. Here is a start it is not correct but its a start, dont quite get the syntax but I know something is missing. $query = "select max(*) from _Replies where LINKID = '$LeadID'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result) or die(mysql_error()); foreach($row as $key => $val) { echo "The highest value is: ".$key." with a value of ".$val; }
  12. One more thing just so its not to confusing. Sold and Closed would not be equal values that would be to confusing Sold would be 5 Closed = 6 Pending = 3 Received = 1 So the table above I have put in the number values instead of the string values.
  13. Look why dont I just replace the values of Sold Closed Pending Received with numbers, how do we do it then. This way maybe use an if statment at the end to say well if the number is 5 print this or if number is 1 print this. So given that the values of the tables are now numbers how do we do it, surely we can just do a select case statement or some if statments to assign which number it is to the value string assigned to the number value.
  14. What about if I were to add a number to the end of each string like this. Sold5 Received1 Pending2 Closed5 And then use some function to pull the last character out of the string work out what is the highest and assign the rest of the string to the variable I need to print on the page. Would that make it easier? Like I said I only under the logic, I programm but not in PHP.
  15. The second table has an incremental key, as well as the field that coresponds to the first table. eg. ID LINKID NOTE STATUS 1 2 bla Received 2 2 bla Pending 3 3 bla Received 4 4 bla Received 5 4 bla Pending 6 4 bla Sold The LINKID field is referenced to the first table, so for each record of the first table there can be many records in the second. So in the code you did the query and used the value of 4 it would pull 3 records. Received Pending Sold But somehow using code how to decifer which one is the highest value. If for instance you did the query using the LINKID 2 you would get two records Received and Pending. Pending is the highest value. The trick is how to to put a value to a string. Or would you recomend some other relationship in the database? To reflect the values of each String
  16. Could someone start the code off so we can start to work through it, if you dont get all of it just put what you have worked out down on the page. I really am a beginner at the syntax I only understand the logic.
  17. I understand that they are string values, but cant you do some fancy code that maybe gives each string a weighting value that is numeric? Or isnt that possible with PHP. Cant you say something like If $String = "Sold" Status.Value = 5 If $String = "Pending" Status2.value = 1 I am not a programmer in PHP so I am only guesing something like this and a loop and the sql query can do it.??? Does this help you understand anymore ?
  18. Okay well say you return back 4 records, these 4 records could look like this. Received. Pending Pending Sold Sold is the highest value so then $coolstatus = "Sold". Lets say the records returned were like this. Received Closed Then the highest value would be Closed and in this case the variable $coolstatus = "Closed" Does that explain enough or do you want me to try again? Thanks heaps for helping.
  19. I have the code below in the space between //-------------- I need to use the value of $LeadID and do a query on the second table to find out all the values and then assign the highest value to a variable $coolstatus. $LeadID is the primary key in the first table, so that needs to be used to find the relating records in the second table, as this is a one to many relationship. In these records on the second table there is a field called Status, the values with in this field are one of four. Received Pending Sold Closed Closed and Sold are equal and the highest Pending is the second lowest and Receved is the lowest rating, I need to find out the highest value and then assign it to a variable. Thats it, any takers? I am guesing it will be a loop inside that loop down there ! <? Print $userid; echo '<table class="tbl" width="100%" border="0" cellpadding="4" cellspacing="1"> <tr> <td width="80"><b>Lead Id</b></td> <td width="110"><b>Industry</b></td> <td width="110"><b>Location</b></td> <td width="110"><b>Date</b></td> <td width="110"><b>Contact</b></td> <td width="70"><b>Replies</b></td> <td><b>Status</b></td> </tr>'; // Define your colors for the alternating rows $color1 = "#ffffff"; $color2 = "#CCFF99"; $row_count = 0; // Perform an statndard SQL query: $sql_events = mysql_query("SELECT * FROM _Leads WHERE LINKID = '$userid'") or die(mysql_error()); // We are going to use the "$row" method for this query. This is just my preference. while ($row = mysql_fetch_array($sql_events)) { $LeadID = $row['ID']; $Industry = $row['Industry']; $Location = $row['Location']; $Date = $row['Date']; $Contact = $row['Contact']; //------------------------------------------------------- //------------------------------------------------------- /* Now we do this small line which is basically going to tell PHP to alternate the colors between the two colors we defined above. */ $row_color = ($row_count % 2) ? $color1 : $color2; // Echo your table row and table data that you want to be looped over and over here. echo '<tr> <td width="80" bgcolor="'.$row_color.'" nowrap>'.$LeadID.'</td> <td bgcolor="'.$row_color.'"> <a>'.$Industry.'</a></td> <td bgcolor="'.$row_color.'"> <a>'.$Location.'</a></td> <td bgcolor="'.$row_color.'"> <a>'.$Date.'</a></td> <td bgcolor="'.$row_color.'"> <a>'.$Contact.'</a></td> <td bgcolor="'.$row_color.'"> <a><form method="POST" action="/replies.php"> <input type="submit" value="'.$LeadID.'" name="getreplies"> </form></a></td> <td bgcolor="'.$row_color.'"> <a>'.$coolstatus.'</a></td> </tr>'; // Add 1 to the row count $row_count++; } // Close out your table. echo '</table>'; mysql_close($db); if ($row_count < 1 ) { echo '<table border="0" cellpadding="3" cellspacing="3" style="border-collapse: collapse" bgcolor="#CCFFCC" width="100%" id="AutoNumber1"> <tr> <td width="100%"><font size="3">'; Print "Please select the creat lead link, to start generating income."; echo '</font></td> </tr> </table>'; } ?>
  20. What I am hoping to do is something like this. Select from BTable where Tablefield = ATable Tablefield. Basically its a one to many relationship and I want to pick the many records that match up with the one from the first table field
  21. Notice the bolded line in include file, I was wondering if someone could show me how to do that properly quit obviously i have the syntax wrong. <td bgcolor="'.$row_color.'"> <a>'.$Location.'</a></td> <td bgcolor="'.$row_color.'"> <a>'.$Date.'</a></td> <td bgcolor="'.$row_color.'"> <a>'.$Contact.'</a></td> <td bgcolor="'.$row_color.'"> <a><form method="POST" action="/replies.php"> <input type="submit" value="'.$LeadID.'" name="getreplies"> </form></a></td> <td bgcolor="'.$row_color.'"> <a>echo [b]'include("status.php")[/b]';</a></td> </tr>'; // Add 1 to the row count $row_count++;
  22. Hey how does that code know the weight or values of each of the words. ???? How does it know that Close or Sold is a numeric value ? of 5 and Received is a value of 1
  23. Thanks heaps not good with php syntax.
  24. I need to search a columb of a table call the colmb Status, each row can have different values like Received. Peding Closed. Sold. And I need to get the value of the highest value, given that each value has a coresponding weight to it. eg. Sold and Closed would be equal and the highest. Received would be the lowest Pending would be second lowest. And what I need to do is find the highest value after searching all the rows. So If you did a search and searched all the rows and found the highest value was Pending a variable would be passed saying Pending or if it was Closed then it would be parsed as closed. Any help would be appreciated.
  25. Tomorrow I will need to write some code, the sql statement will need to check more than one pair of variables passed. Can this be done in an sql statment? I have never done it before. It would go something like SELECT FROM TABLE WHERE X = VAR1 AND Y = VAR2 OR X = VAR2 AND Y = VAR3 OR ETC ETC.
×
×
  • 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.