PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and I need to figure out how to get the 2nd query string to tack on to the first one. I have tried to do it with the ? and the & character, but neither one has worked. All they do is generate an error or show the same page after I click it.
Any ideas would be greately appreciated!
Thanks!
<?php
$GLOBALS['which'] = explode("-", $GLOBALS['which']);
switch ($GLOBALS['which'])
case "value1":
if blah blah blah
case "value2":
if blah blah blah
?>
Now heres the problem. Value 1 and value 2 are both table definitions for mySql, and I need both value 1 and value 2 in the same case, but I don't know how to pull that from the explode.
Now heres the problem. Value 1 and value 2 are both table definitions for mySql, and I need both value 1 and value 2 in the same case, but I don't know how to pull that from the explode.
So, let's pretend you have the value "username-password", and you want to retreive "username" and "password" separately, to reference them as table names? Try this code:
$string = "username-password";
$array = explode("-",$string);
// Now we've got $array[0], which equals "username", and $array[1], which equals "password".
Right, I have that already, but the problem isn't really that anymore. The problem is the switch statement in the prior post. I need both values to be accounted for in the fist case because whatever $GLOBALS['which'] is, becomes a table query. so I need both value1 and value2 to appear be in the same case argument, AND they also have to function properly in a mysql query statement. That is my real question.
<?php
// <option> is username-password and send from a form...
// put them in array...
$foo = explode("-", $_POST['which']);
// use the two to get selections...
$clause = " username = '$foo[0]' and password = '$foo[1]'";
// add it to a query...
$queryexample = 'select * from users'.$clause;
// merge the two, and test the statement...
switch ($foo[0].$foo[1]) {
case "usernamepassword":
// code
//...
}
?>
<?php
$passedVars = explode("-", $GLOBALS['which']);
// gets variables and puts them into an array.
$storedVars = $passedVars[0] ."AND". $passedVars[1];
// gets vars from array and puts them into a db compatible form.
print($storedVars); // This is for Error Checking only
$this->oView->table = $storedVars;
switch($passedVars[0].$passedVars[1])
{
case 'workorderstimecards':
//code to execute
}
?>
Now the problem is, when I try to execute it, I get "error" as the error message, or messing with it in other ways I get "unknown table workorders AND timecards". I need the query to look in both the tables workorders and timecards.
I can get it to do one at a time by making them both individual options and setting a case for each... and making the table call
umm...When I think of a good answer as to why I didn't do it that way, I'll tell ya. Until then, I got it to sorta work, now the problem is that I am getting a sql syntax error in one of the calls.. and I'm not quite sure as to what the problem is, but its doing half of what I wanted, which is better than where I was a few hours ago. Thanks for the help, and I might be back later ^_^
<?php
function searchWorkorders()
{
$this->oView->table = 'workorders';
//code
}
function searchTimecards()
{
$this->oView->table .= 'timecards';
//code
}
?>
What do I need to put before the 'timecards' to make it query that table as well as the workorders table. I have tried 'AND timecards', and ',timecards'. Neither of these worked. Any other ideas.
Thanks
SELECT a.foo1, b.bar FROM `table1` as a, `table2` as b WHERE a.feild = b.feild2 AND b.feild3 = 'value'
With limits, orders and groupings following that. Basically, you're calling table1 'a', and table2 'b', and then referencing them via table.feild.
If you wanted to retreive a username based on a user id from the table "user_data", AND retreive an email address from "user_details" with that username, you would use..