Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts

    List everything that meets criteria

    Ok, I've selected the rows from my database, and assigned it to variables.

    Now I need to list everything that falls under the "Where row=value" criteria. Basically a giant list of everything that is in it.

    My problem understanding how it would work is, i don't see how the variables would change less i changed the extraction method...


    I also need an advanced MySQL query, how would I set more than one criteria. Would it be like...

    SELECT * FROM table WHERE row=value && row=value ?

    And...

    After all of the above, where I get everything..

    How would I set it so it displays, for instance 30, random results that match the criteria?

  • #2
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Quote Originally Posted by Deacon Frost View Post
    Now I need to list everything that falls under the "Where row=value" criteria. Basically a giant list of everything that is in it.
    PHP Code:
    <table border="0" cellpadding="3" cellspacing="0">
       <tr>
          <th>Col1</th>
          <th>Col2</th>
          <th>Col3</th>
       </tr>
    <?php

    $query 
    mysql_query("SELECT * FROM table");
    while (
    $results mysql_fetch_array($query))
    {
    ?>
       <tr>
          <td><?php echo $results["Col1"]; ?></td>
          <td><?php echo $results["Col2"]; ?></td>
          <td><?php echo $results["Col3"]; ?></td>
       </tr>
    <?php
    }

    ?>
    Quote Originally Posted by Deacon Frost View Post
    I also need an advanced MySQL query, how would I set more than one criteria.
    PHP Code:
    SELECT FROM table WHERE col='value' AND col2='value2' 
    Quote Originally Posted by Deacon Frost View Post
    How would I set it so it displays, for instance 30, random results that match the criteria?
    PHP Code:
    SELECT FROM table LIMIT 30 
    Unfortunately there is no random command for MySQL

    Hopefully this helps, you'll need to change the names of everything though since you didn't post your schema...

  • #3
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    thanks! I'ma update right now to see if I can alter it correctly to get it to work.

    Unfortunately, everything above is gonna be used on one page XD!

    EDIT:

    But wait, I need to display 30 of the results using variabls. saying col1, col2, and col3 will only display the same results...

    like so:

    http://downstage.tv/test.php

    :S

  • #4
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    PHP Code:
    <?php
    include("/home/stage/public_html/css/inc/theaterconn.php"); 

    $sql "SELECT id,filmid,name FROM theater WHERE status='2' LIMIT 2 ORDER BY id";
    $result mysql_query$sql ) or die('mysql_error()' 'Error:  ' mysql_errno() );
    $row mysql_fetch_assoc($result);
    $num mysql_num_rows($result);

    $id $row['id'];
    $filmid $row['filmid'];
    $name $row['name'];

    ?>



    <table>
    <tr>
    <td>
    <form action="theater.php" method="get">
    <input type="hidden" name="id" value ="<? echo $id ?>">
    <input type="image" src="http://images.stage6.com/video_images/<? echo $filmid ?>t.jpg" value="Submit" alt="Go to Theater">
    <br />
    <center><? echo $name ?></center>
    <tr>
    <td>
    <input type="hidden" name="id" value ="<? echo $id ?>">
    <input type="image" src="http://images.stage6.com/video_images/<? echo $filmid ?>t.jpg" value="Submit" alt="Go to Theater">
    <br />
    <center><? echo $name ?></center>
    </form>
    </tr>
    </table>
    mysql_error()Error: 1064


    Basically... I need it to behave much like that of comments. It needs to show the data in a table listed by the ID number, displaying only those that meet the criteria of the SQL database, and I want it to display 30 of them.

    EDIT: (if I take out the LIMIT 2, then it shows TWO of the same image w/ the same database data. Instead of retrieving the other row's data and putting it in there...)


    After trying something else:

    PHP Code:
    <?php
    include("/home/stage/public_html/css/inc/theaterconn.php"); 

    $sql "SELECT id,filmid,name FROM theater WHERE status='2' ORDER BY id";
    $result mysql_query$sql ) or die('mysql_error()' 'Error:  ' mysql_errno() );

    while(
    $row mysql_fetch_array($result));


    $id $row['id'];
    $filmid $row['filmid'];
    $name $row['name'];
     
    {

    echo 
    "<table>";
    echo 
    "<tr>";
    echo 
    "<td>";
    echo 
    "<form action='theater.php' method='get'>";
    echo 
    "<input type='hidden' name='id' value="
    echo 
    $id ">";
    echo 
    "<input type='image' src='http://images.stage6.com/video_images/";
    echo 
    $filmid "t.jpg' value='Submit' alt='Go to Theater'>";
    echo 
    "<center>"
    echo 
    $name "</center>";
    echo 
    "</form>";
    echo 
    "</tr>";
    echo 
    "</table>";
    }
    ?>

    It kept some things, but some things didn't work, experimenting w/ that to see what I get... >.>


    (It seems when I do this, it doesn't display the image =/.)
    Last edited by Deacon Frost; 02-16-2008 at 09:01 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •