Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
finally I used successfully this mysql VIEW code with one error
Old 11-02-2008, 12:04 PM finally I used successfully this mysql VIEW code with one error
Experienced Talker

Posts: 34
Trades: 0
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' ";
Attached Images
File Type: gif view-adv.gif (36.0 KB, 8 views)
lse123 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-02-2008, 12:19 PM Re: finally I used successfully this mysql VIEW code with one error
Experienced Talker

Posts: 34
Trades: 0
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. )";
?>
lse123 is offline
Reply With Quote
View Public Profile
 
Old 11-02-2008, 05:46 PM Re: finally I used successfully this mysql VIEW code with one error
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-14-2008, 04:16 PM Re: finally I used successfully this mysql VIEW code with one error
Experienced Talker

Posts: 34
Trades: 0
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

lse123 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to finally I used successfully this mysql VIEW code with one error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20396 seconds with 13 queries