finally I used successfully this mysql VIEW code with one error
11-02-2008, 12:04 PM
|
finally I used successfully this mysql VIEW code with one error
|
Posts: 34
|
finally I used successfully this mysql VIEW code with one error: I and entries with $CustomersTable.status = 'deleted' rather than the wanted ONLY entries with $CustomersTable.status = 'active', where is the problem ?
as you see in the attachment there are two BID=6 one with a/c status=deleted and one with status=active ...well ?
Code:
$query_view = "CREATE VIEW admin_bookings (name,mob,fixed,email,bookingid,dateplaced,status,datep,dated,Locationp,Locationd,days,mostdaysrate,vat,off,total,cat) AS
SELECT $CustomersTable.name,$CustomersTable.mob,$CustomersTable.fixed,$CustomersTable.email,$BookingsTable.bookingid,$BookingsTable.dateplaced,$BookingsTable.status,$BookingsTable.datep,$BookingsTable.dated,$BookingsTable.Locationp,$BookingsTable.Locationd,$BookingsTable.days,$BookingsTable.mostdaysrate,$BookingsTable.vat,$BookingsTable.off,$BookingsTable.total,$BookingsTable.cat
FROM $CustomersTable, $BookingsTable
WHERE $CustomersTable.email = $BookingsTable.email AND $CustomersTable.status = 'active' ";
|
|
|
|
11-02-2008, 12:19 PM
|
Re: finally I used successfully this mysql VIEW code with one error
|
Posts: 34
|
MORE CODE:
Code:
include("../dbinfo.php");
$linkid = mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database"); // @
// Base query
$today = time()-30*24*60*60;
$query ='';
// $email6=$_SESSION['email']; //from above non needed
if (($_GET['orderby'] == "") && ($_SESSION['orderby'] == "")) {
$_SESSION['orderby'] = "dateplaced DESC";
$orderby = $_SESSION['orderby'];
} else if (($_GET['orderby'] != "") && (($_SESSION['orderby'] == "") || ($_SESSION['orderby'] != ""))) {
$orderby = $_GET['orderby'];
$_SESSION['orderby'] = $orderby;
} else if (($_GET['orderby'] == "") && ($_SESSION['orderby'] != "")) {
$orderby = $_SESSION['orderby'];
}
// $query = "SELECT * FROM $BookingsTable WHERE dated>='$today' ORDER BY $orderby "; // dateplaced dated AND dated>='$today'"; email='$email6' AND status!='canceled' // appear bookings dated>=time() AND time()<='$dated'canceled
// $result = @mysql_query($query,$linkid);
// -----------
$active = 'active';
$query_view = "CREATE VIEW admin_bookings (name,mob,fixed,email,bookingid,dateplaced,status,datep,dated,Locationp,Locationd,days,mostdaysrate,vat,off,total,cat) AS
SELECT $CustomersTable.name,$CustomersTable.mob,$CustomersTable.fixed,$CustomersTable.email,$BookingsTable.bookingid,$BookingsTable.dateplaced,$BookingsTable.status,$BookingsTable.datep,$BookingsTable.dated,$BookingsTable.Locationp,$BookingsTable.Locationd,$BookingsTable.days,$BookingsTable.mostdaysrate,$BookingsTable.vat,$BookingsTable.off,$BookingsTable.total,$BookingsTable.cat
FROM $CustomersTable, $BookingsTable
WHERE $CustomersTable.email = $BookingsTable.email AND $CustomersTable.status = $active ";
// ----------
$result_view = @mysql_query($query_view,$linkid);
$query = "SELECT * FROM admin_bookings WHERE dated>='$today' ORDER BY $orderby "; // dateplaced dated AND dated>='$today'"; email='$email6' AND status!='canceled' // appear bookings dated>=time() AND time()<='$dated'canceled
$result = @mysql_query($query,$linkid);
$count = @mysql_num_rows($result);
echo " ( Your query returned " . $count . " items. )";
?>
|
|
|
|
11-02-2008, 05:46 PM
|
Re: finally I used successfully this mysql VIEW code with one error
|
Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
|
PHP problem
echo out the queries after concatenation so you can SEE what you send to the database.
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
|
|
|
|
11-14-2008, 04:16 PM
|
Re: finally I used successfully this mysql VIEW code with one error
|
Posts: 34
|
other problem:
MySQL 5 - I delete view from phpMyAdmin,well now I rerun php file but VIEW does not getRecreate
I do a MYSQL VIEW I think via running a php file with
Code:
$active = 'active';
$query_view2 = "CREATE VIEW admin_bookings2 (name,mob,fixed,cstatus,email,bookingid,dateplaced ,status,datep,dated,Locationp,Locationd,days,mostd aysrate,vat,off,total,cat,discount2) AS
SELECT $CustomersTable.name,$CustomersTable.mob,$Customer sTable.fixed,$CustomersTable.status,$CustomersTabl e.email,$BookingsTable.bookingid,$BookingsTable.da teplaced,$BookingsTable.status,$BookingsTable.date p,$BookingsTable.dated,$BookingsTable.Locationp,$B ookingsTable.Locationd,$BookingsTable.days,$Bookin gsTable.mostdaysrate,$BookingsTable.vat,$BookingsT able.off,$BookingsTable.total,$BookingsTable.cat,$ BookingsTable.discount2
FROM $CustomersTable, $BookingsTable
WHERE $CustomersTable.email = $BookingsTable.email AND cstatus='active'"; //$CustomersTable.status = $active
// ----------
$result_view = @mysql_query($query_view2,$linkid);
$query = "SELECT * FROM admin_bookings2 WHERE dated>='$today' ORDER BY $orderby "; // dateplaced dated AND dated>='$today'"; email='$email6' AND status!='canceled' // appear bookings dated>=time() AND time()<='$dated'canceled
$result = @mysql_query($query,$linkid);
$count = @mysql_num_rows($result);
echo " ( Your query returned " . $count . " items. )";
?>
but I delete it from phpMyAdmin by error, well now I return to php file but VIEW does not get recreated, what to do ?
in php file appears:
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/content/p/o/l/polisch123/html/administration/bookings10nov2008.php on line 213
|
|
|
|
|
« Reply to finally I used successfully this mysql VIEW code with one error
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|