Jump to content

siric

Members
  • Posts

    116
  • Joined

  • Last visited

Posts posted by siric

  1. //Connect To Database

     

    $hostname="HOSTNAME PROVIDED BY GoDADDY.hostedresource.com";

    $username="MY USERNAME";

    $password="MY PASSWORD";

    $dbname="vixtay.db";

    $usertable="members";

     

    This is the info on GoDaddy under MySql:

    Status:Setup

    Host Name:vixtay.db.4394481.hostedresource.com

    Database Name:vixtayDatabase

     

    Your script shows the database name as "vixtay.db", yet the GoDaddy information shows the name as "vixtayDatabase".

     

     

  2. You can use the MySQL function Format to add the comma's before displaying. If you want the user to input the value as a string with commas in it simply strip them out by str_replacing ',' with ''. That's assuming mysql won't accept an Integer with them in (which I don't think it will, but I've not tested it).

     

    This is the way to go.  Integer will not allow commas (it strips anything after). 

  3. You need to run a select for each year and order the results

     

    Say you had a table named TABLE with columns DATE and VALUE.

     

    
    $sqlYear = "SELECT DISTINCT YEAR(datepro) AS YEAR FROM factory_output ORDER BY YEAR DESC;";  //This will select all unique instances of the year from the date field and sort them in descending order
    
    $resYear = mysql_query($sqlYear);
    $numYear = mysql_num_rows($resYear);
    
    for ($i = 0; $i < $numYear; $i++) {
    
         $year = mysql_result($resYear,$i,'year');
    
         $sqlValue = "select VALUE from TABLE where year = '$year' order by VALUE";
         $resValue = mysql_query($sqlValue);
         $numValue = mysql_num_rows($resValue);
    
         echo "$year <br />;
         echo "--------- <br />;
    
         for ($j=0; $j < $numValue ;j++) {  //Rotates through each instance of the value for that year
              $value = mysql_result($res,$j,'value');
              echo "$value <br />;
         }
    
         echo "<br />";
    }
    
    

     

    Wrote this on the fly, so give this a wing and let us know.

  4. my bad, try this:

     

    <?php
    echo '<input type="radio" value="1" name="quality"'.(($var1 == '1') ? ' checked' : '').'" />';
    ?>

     

    i had given you the wrong comparable (= instead of ==) .. try this code now.

     

    EDIT: for the record, i rarely test code that i post.

     

    That was the problem.  I started from an if statement from scratch and realised just before I saw this post.

     

     

    Much Thanks.

  5. Hi,

     

    I am pulling data from a database to populate a form for editing purposes.  The form includes many radio buttons.

     

    Is there a more elegant way to accomplish this than the following -

     

    if ($var1 = '1') {
      print "<input type='radio' value='1' checked name='quality'>1<p>;
    } else {
      print "<input type='radio' value='1' name='quality'>1<p>;
    }
    
    if ($var1 = '2') {
      print "<input type='radio' value='2' checked name='quality'>2<p>;
    } else {
      print "<input type='radio' value='2' name='quality'>2<p>;
    }
    ......
    
    

     

     

    Thanks

     

     

  6. [!--quoteo(post=363665:date=Apr 11 2006, 02:20 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 11 2006, 02:20 PM) [snapback]363665[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Firtly, the Msxml2.ServerXMLHTTP object is not a native asp object, but an extension. It looks like most of this functionality would be available in php's [a href=\"http://php.net/curl\" target=\"_blank\"]curl[/a] extension though.

    Server.Createobject = curl_init()
    oXmlHttp.setRequestHeader = curl_setopt()
    oXmlHttp.send = curl_exec()
    Response.Write = echo()
    [/quote]


    Thanks for the info.
  7. Hi,

    I have a short script that I need to convert from ASP to PHP. It basically pushs headers and variables through a URL from a form.


    [code]

    ' Assign values to variables
    strURL = "http://192.168.254.1:7000/"
    varRecipient = Request("frmPhone") & ":1:1"
    varSubject = Request("frmSubject")
    varMessage = Request("frmMessage")
    varContentLength = Len(varSubject) + Len(varMessage)

    Set oXmlHttp = Server.Createobject("Msxml2.ServerXMLHTTP")

    oXmlHttp.open "POST", strURL, False

    Call oXmlHttp.setRequestHeader("Host","Host")
    Call oXmlHttp.setRequestHeader("X-Service","service")
    Call oXmlHttp.setRequestHeader("X-Password","password")
    Call oXmlHttp.setRequestHeader("X-Sender","sender")
    Call oXmlHttp.setRequestHeader("X-Recipient",varRecipient)
    Call oXmlHttp.setRequestHeader("Content-Length",varContentLength)

    oXmlHttp.send(varSubject & varMessage)

    If (oXmlHttp.status <> 200) Then
      ' If not successful display error response text and code
      strReturn = oXmlHttp.responseText
      Response.Write(strReturn & "<br>")
      Response.Write(oXmlHttp.status & "<br>")
      Response.Write(oXmlHttp.readyState & "<br><br>")
      Response.Write("Error!! <br><br>")
    Else
      ' Else display sms sent
      Response.Write("<b>All Ok!</b> <br><br> Recipient(s): " & Request("frmPhone") & "<br> Subject: " & varSubject & "<br> Message: " & varMessage & "<br><br>")
    End If

    [/code]


    So I am trying find the equivalent of

    Server.Createobject,
    oXmlHttp.setRequestHeader,
    oXmlHttp.send,
    Response.Write

    It is possible? My research is pointing me in the direction of AJAX. Is that the only option?

    Thanks

    Steve
×
×
  • 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.