Jump to content

RON_ron

Members
  • Posts

    370
  • Joined

  • Last visited

Posts posted by RON_ron

  1. How can I get the count value in a sequence? (first count AZ then MI then WD tec...) and then echo it in the same seuence. Please help. This is what I've done so far.

     

    $SomeVar = "AZ";
    $query1 = "SELECT statez, COUNT(statez) AS Tstate FROM  distributors WHERE statez = '".$SomeVar."'";
    $results1 = mysql_query($query1);
    
    $SomeVar = "MI";
    $query2 = "SELECT statez, COUNT(statez) AS Tstate FROM  distributors WHERE statez = '".$SomeVar."'";
    $results2 = mysql_query($query2);
    
    $SomeVar = "WD";
    $query3 = "SELECT statez, COUNT(statez) AS Tstate FROM  distributors WHERE statez = '".$SomeVar."'";
    $results3 = mysql_query($query3);
    
    $values = array();  
    
    while($line = mysql_fetch_array($results))
    {
        $values[] = $line;
    }
    
    echo $values[0]['Tstate'].",,";
    echo $values[1]['Tstate'].",,";
    echo $values[2]['Tstate'].",,";
    echo $values[3]['Tstate'].",,";
    mysql_close($link);
    ?>

  2. I need to get the 2nd code working. Please help.

     

    This works

    $query = "SELECT DISTINCT addressz FROM abs WHERE statez = 'AZ'";
    $results = mysql_query($query);

     

    But this dosen't.

    $SomeVar = $_POST['disloc'];
    $query = "SELECT DISTINCT addressz FROM abs WHERE statez = '".$SomeVar."' ORDER BY addressz ASC";
    $results = mysql_query($query);

     

  3. How do I pull data by ignoring duplicate records?

     

    E.g. I've got 100 types of books and a field in mysql saying 'category'. In the books I've got 20 books as history, 5 books as agriculture, etc...

     

    I need the data displayed only the types of categories.

    history

    agriculture

    etc...

     

    $SomeVar = $_POST['finco'];
    $query = "SELECT * FROM  abcs WHERE typesz = '".$SomeVar."' ORDER BY typesz ASC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {

  4. I want to pull the mysql data in an alphabetical order suburbz. This code is not getting the results in an alphabetical order. Please help.

     

    $SomeVar = $_POST['disloc'];
    $query = "SELECT * FROM  books WHERE statez = '".$SomeVar."' ORDER BY suburbz ASC";
    $results = mysql_query($query);

  5. I'm using this to pull in data in to my flash website. I need to get the COUNT value of each state as separated/ as individual outputs. Because I need to load the values in separate text boxes in several locations.

     

    E.g.

    Assume the echo gives the following results.

    STATE A - 12

    STATE B - 30

    STATE C - 41

    STATE D - 11

     

    I need php to send them individually in several echos.

    echo $line["number_of_friends_in_state_1"].",,";

    echo $line["number_of_friends_in_state_2"].",,";

    echo $line["number_of_friends_in_state_3"].",,";

    etc...

     

  6. IS it possible to split the results in to several echos?

     

    $query = "SELECT statez, COUNT(statez) AS Tstate FROM abs GROUP BY statez"; 
    $results = mysql_query($query) or die( "Query Error: " . mysql_error());
    
    while($line = mysql_fetch_array($results))
    {
       // here you can display your record in any format that you want  probably in a html table
    echo $line['Tstate1'] . " ----- " . $line['statez1'].",,";
    echo $line['Tstate2'] . " ----- " . $line['statez2'].",,";
    echo $line['Tstate3'] . " ----- " . $line['statez3'].",,";
    echo $line['Tstate4'] . " ----- " . $line['statez4'].",,";
    echo $line['Tstate5'] . " ----- " . $line['statez5'].",,";
    }
    mysql_close($link);
    ?>

  7. I'm getting the number of friends in each STATE. How do I split the results in $returnS?

     

    $query = "SELECT statez, COUNT(statez)FROM abs GROUP BY statez"; 
    $results = mysql_query($query);
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

  8. I'm pulling 10 records here. How do I split the results in to several echos?

     

    $query = "SELECT statez, COUNT(statez)FROM mylist GROUP BY statez"; 
    $results = mysql_query($query);
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

     

    I need the code to look like this by showing the (COUNT) number for each state.

    $results = mysql_query($query);
    while($line = mysql_fetch_array($results))
    {
    echo $line["number_in_state1"].",,";
    echo $line["number_in_state2"].",,";
    echo $line["number_in_statee3"].",,";
    echo $line["number_in_state4"].",,";
    echo $line["number_in_state5"].",,";
    echo $line["number_in_state6"].",,";
    //etc....
    }

  9. I want to modify a record in my mysql. But this code doesn't seem to work. Could you please help?

     

    $SomeVar = $_POST['finco'];
    mysql_query("UPDATE distributors SETsuburbz='$addressx', addressz='$suburbx', statez='$statex', postalz='$postalx', countryz='$countryx', telephonez='$telephonex', emailz='$emailx', companyz='$companyx' WHERE codez = '".$SomeVar."'");
    
    $result = mysql_query($query);
    
    $sentOk = "Edit Successful!";
    echo "sentOk=" . $sentOk;
    ?>

  10. my mysql has got a field called statez where it stores the STATE. How do I amend the code below by adding $SomeVar = $_POST['Hamburg']; to count the number of records of a particular state? ($SomeVar will represent the state)

     

    $query = "SELECT statez, COUNT(statez)FROM distributors GROUP BY statez"; 	 
    $results = mysql_query($query);
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,";
    }
    echo $returnS;

  11. statez : I need to sort the results from the high score to the low score.

     

    $query = "SELECT statez, COUNT(statez)FROM distributors GROUP BY statez"; 
    $results = mysql_query($query);
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

  12. How do I get the number as pairs? (i.e. 05, 20, 01, 70)

     

    $query = "SELECT statez, COUNT(statez)FROM distributors GROUP BY statez";

     

    $result = mysql_query($query) or die(mysql_error());

     

    while($row = mysql_fetch_array($result)){

    echo $row['COUNT(statez)'] ." Distributors in ". $row['statez'];

    echo "<br />";

    }

    ?>

  13. I need to pull data in an alphabatical order based on a certain field.

     

    I'm trying to display the results, sorted according to the alphabatical order of the data in addressz... The my code dosen't do that, it pulls the data according to the order which I've entered the data.

     

    $SomeVar = $_POST['sta'];
    $query = "SELECT * FROM  shops WHERE statez = '".$SomeVar."' ORDER BY addressz ASC";
    $results = mysql_query($query);

  14. ...The field is a DATETIME field, and the values are in there as YYYY-MM-DD HH:MM:SS, right?

     

    Can you post any errors, and whatever part of it looks weird?

     

    $query = "SELECT subjectz, DATE_FORMAT(timestampz, '%d/%m/%Y') AS timez, Newsz, linksz FROM news_homez ORDER BY timestampz DESC";
    

     

    Hi Pickachu...

     

    yes it is YYYY-MM-DD HH:MM:SS.

     

    I'm getting ONLY THE DATE and NO other data. It seems only 2 lines are the idfference between the working code and the not working code. That's weird!

     

    Works alright (without the required date format from the date field).

    $date =date('d-m-Y');
    $query = "SELECT * FROM  news_homez ORDER BY timestampz DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line["subjectz"].",,".$date.",,".$line["Newsz"].",,".$line["linksz"].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

     

    Pulls ONLY the date.

    $query = "SELECT DATE_FORMAT(timestampz, '%d/%m/%Y') AS timez FROM news_homez ORDER BY timestampz DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line["subjectz"].",,".$line["timez"].",,".$line["Newsz"].",,".$line["linksz"].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

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