Jump to content

JD*

Members
  • Posts

    230
  • Joined

  • Last visited

Everything posted by JD*

  1. What is the error/result that you get? A blank return?
  2. Are you looking to convert video that you upload to flv? Or take flv videos from online and convert them to something else?
  3. I'm assuming that you're going to be setting this up as a form, so it will take user input before showing the final query. I would wrap the whole page like this: include "../scripts/connection.php"; if (!$conn) { die( 'Could not connect: ' . mysql_error() ); } mysql_select_db($db, $conn); if(isset($_POST['Submit'])){ $query = "SELECT * FROM database"; if(sizeof($_POST) > 1) { $query.=" WHERE"; } for($i=0;$i<sizeof($_POST);$i++) { if($_POST == "Submit") { continue(); } if(value($_POST[$i]) == '') { continue(); } else { $query.= " ".key($_POST[$i])." = '".value($_POST[$i])."'"; if($i+1 < sizeof($_POST)) { $query.=" AND"; } } } echo $query; // - Uncomment this after the query looks right: $result = mysql_query($query) or die(mysql_error()); } else { $sql="SELECT DISTINCT (loginid), albumname FROM orders"; //GENERATES A DROPDOWN OF ALBUM NAMES $sql2="SELECT DISTINCT DATE_FORMAT(orderdate, '%M') AS month, month(orderdate) AS monthnum FROM orders ORDER BY monthnum asc"; //GENERATES A DROPDOWN OF MONTHS IN USE $sql3="SELECT DISTINCT YEAR(orderdate) AS year FROM orders ORDER BY orderdate asc"; //GENERATES A DROPDOWN OF YEARS IN USE $sql4="SELECT DISTINCT (status) FROM orders ORDER BY status desc"; //GENERATES A DROPDOWN OF STATUS IN USE $sql5="SELECT * FROM album WHERE login = '$albumname'"; $sql10="SELECT * FROM orders WHERE loginid = '$albumname' ORDER BY orderdate desc "; //THIS IS THE ONE I WAS TRYING TO WORK ON $result=mysql_query($sql)or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql<br><br>" ); $result2=mysql_query($sql2)or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql2<br><br>" ); $result3=mysql_query($sql3)or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql3<br><br>" ); $result4=mysql_query($sql4)or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql4<br><br>" ); $result5=mysql_query($sql5)or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql5<br><br>" ); $result10=mysql_query($sql10)or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql10<br><br>" ); // form code goes here, ending with a submit button called "Submit" } I updated the code with the dynamic query...it should search your $_POST variable (that comes from the form) and will add the field name and it's value, providing that the field value is anything other than '' and it will also keep putting in an "AND" until we reach the end of the $_POST variable. At the end, it will echo out the query, so we can make sure it does it correctly. Again, I didn't get a chance to test this, so it may not work at all, but give it a shot and see what happens.
  4. For this type of query, I would use some PHP to construct it, along the lines of: $query = "SELECT * FROM database WHERE"; if($_POST['albumname'] != '') { $query.=" albumname=.'".$_POST['albumname']."'"; } if($_POST['month'] != '') { $query.=" AND month=.'".$_POST['month']."'"; } if($_POST['year'] != '') { $query.=" ABD year=.'".$_POST['year']."'"; } if($_POST['status'] != '') { $query.=" AND status=.'".$_POST['status']."'"; } $result = mysql_query($query) or die(mysql_error()); That should do it for you. You will have a problem with this if there is no album name (as you can't have "AND" as the first part of the query), but I don't have access to a server at the moment to construct and test a more dynamic query. If you're interested in that, send me a PM and I'll construct one when I have access again.
×
×
  • 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.