Jump to content
Larry Ullman's Book Forums

skim5_1999

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by skim5_1999

  1. HartleySan, Thank you and please don't feel the need to apologize when you are trying to generously help me during your spare time. Your logic makes sense and another developer friend commented the same.I'll try to see how to hold back the ajax trigger until after the radio buttons have loaded. The most frustrating thing is that the firebug console shows nothing.. no errors..not even a little help. My condolence to you for only having IE6 to work with! Thank you again
  2. Hi, HartleySan, Actually, the problem really seems to be the fact that the below jquery ajax code isn't firing up because it's preceded/called upon by another set of ajax. If I tried to open this file on my own, the calendar.html file opens up beautifully...but it's only when the file is opened via a preceding ajax Get call. I'm at the end of my wits - any chance you can see what's wrong with the codes below so that when it's preceded by another ajax, it doesn't get triggered? I've heard that "bind" or "live" could help, but I don't know jquery enough to know how to effectively incorporate this. Many thanks in advance for your guidance. $(document).ready(function() { $('.button').click(function() { var valueSelected = this.value; var buttonSelected = this.id.replace(valueSelected + '_',''); //alert('Button Selected: ' + buttonSelected + "\nValue Selected: " + valueSelected); $.ajax({ url: 'calendar.html', //data: '', cache: false, async: false, success: function(result) { $('#ajaxDiv').html(result); }, error: function (response, desc, exception) { // custom error } }); }); });
  3. Hello, HartleySan! Yes, this is the same topic I started awhile ago. I followed through what you recommended above and was able to get the datepicker dynamically appear based on selected radio button. So that's progress...! BUT!! my problem is still integrating this to the steps which precede it.... I have ajax calls in two successive motions and they seem to conflict with each other. More specifically.,.With my reservation form (1) You first select # of people via dropdown. The value you select here then calls a "roomselect.php" script via ajax (2) then the radio buttons from roomselect.php shows up via an initially hidden div. Again, the button selected here opens the "calendar.html" URL via ajax which is displayed on the same page via an initially hidden div. Because i was having so much trouble just getting the datepicker to show up, I tried to build step #2 above separately from #1. I got #2 to work fine. But now I'm trying to integrate the working #2 to #1, and for some reason the successive ajax calls cause a conflict. The jquery ajax in step #2 won't even fire up. The codes to step #1 is as follow <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/ajax.js"></script> <script type="text/javascript"> function showUser(str) { var venue = '<?php echo $_GET['VenueID'] ?>'; if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange=function() { if (ajax.readyState==4 && ajax.status==200) { document.getElementById("txtHint").innerHTML=ajax.responseText; } } //xmlhttp.open("GET","test.php?c="+str,true); ajax.open("GET","roomselect.php?c="+str+"&venue="+venue,true); ajax.send(null); } </script> </head> <body> <form> <select name="username" onchange="showUser(this.value)"> <?php $venue = $_GET['VenueID'];?> <option value="">Select # of People here </option> <?php while ($row=mysql_fetch_array($result)) { echo "<option value=\"".$row['Capacity']."\""; echo ">".$row['Capacity']."</option>\n"; ; } ?> </select> </form> <div id="txtHint"><b>List of Rooms with radiobuttons will be listed here.</b></div> </body> The codes to step #2 is as follow. The "alert" attempt won't even work so the ajax isn't working. I've tried building in jquery no conflict, etc. but to no avail. Again, this file works if it's fired up independently from step #1. Can you help? <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function() { $('.button').click(function() { var valueSelected = this.value; var buttonSelected = this.id.replace(valueSelected + '_',''); //alert('Button Selected: ' + buttonSelected + "\nValue Selected: " + valueSelected); $.ajax({ //type: "GET", url: 'calendar.html', //url: 'test.php?entered=' + valueSelected + '&id=' + buttonSelected, dataType: 'html', cache: false, async: false, success: function(data) { $('#ajaxDiv').html(data); //$('#ajaxDiv').load("calendar.html"); //$( "#datepicker" ).datepicker(); }, error: function (response, desc, exception) { // custom error } }); }); }); </script> <fieldset> <legend>Posts</legend> <?php $c=$_GET["c"]; $id = &$_GET["venue"]; $con = mysql_connect('DBHOST', 'USERNAME', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DBNAME", $con); $sql="SELECT * FROM venue_room WHERE MaxCap > $c and VenueID =$id"; ; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo' <input type="radio" id='.$row['RoomID'].' value='.$row['RoomID'].' name="selected_room" class="button" /> <label for='.$row['RoomID'].'>'.$row['RoomID'].'</label> <br/> ' ; } ?> </fieldset> <div id="ajaxDiv">calendar should show here</div>
  4. Hello, Hartleysan Apologies for not getting back. I ended up finding different set of codes which worked . I posted it under a different question I just posted under "Ajax & posting radio button". I've been trying to build this dynamic reservation system for ages now and seems to get stuck every time I think I have it sorted. I'd greatly appreciate your reply to the new topic if you have the chance as it's taken the question I've written above to an progressive stage.
  5. Hello I'm building a restaurant reservation form which needs to do 3 things - 1) Allow users to input # of people reserving for (Drop down) 2) Then dynamically based on # of people show available rooms (Radio button) 3) Then based on selected room, show date availability via (jquery datepicker) I need all 3 items to access mysql database and appear on same page without refresh. I have 1 & 2 working well but can't figure out how to pass on #2's selected room value onto a php and datepicker id to show dynamically. However, #3, as an independent file actually works well. Hence I have a challenge of linking 2 to #3. I'd greatly appreciate your expert input and apologies in advance for the length of the codes below. View.html <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/ajax.js"></script> <script type="text/javascript"> function showUser(str) { var venue = '<?php echo $_GET['VenueID'] ?>'; if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange=function() { if (ajax.readyState==4 && ajax.status==200) { document.getElementById("txtHint").innerHTML=ajax.responseText; } } //xmlhttp.open("GET","test.php?c="+str,true); ajax.open("GET","roomselect.php?c="+str+"&venue="+venue,true); ajax.send(null); } </script> </head> <body> <form> <select name="username" onchange="showUser(this.value)"> <?php $venue = $_GET['VenueID'];?> <option value="">Select # of People here </option> <?php while ($row=mysql_fetch_array($result)) { echo "<option value=\"".$row['Capacity']."\""; echo ">".$row['Capacity']."</option>\n"; ; } ?> </select> </form> <br /> <br /> <br /> <div id="txtHint"><b>Person info will be listed here. </b></div> <br /> <br /> <br /> <h3>Would like to show a button that upon clicking, would show datepicker here</h3> <br/> </body> Here's the Roomselect.php which the above references and contains the radio select buttons for rooms. <?php $c=$_GET["c"]; $id = &$_GET["venue"]; $con = mysql_connect('DBHOST', 'DBUSER', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DBNAME", $con); if(isset($id ) && is_numeric($id)) { $sql="SELECT * FROM venue_room WHERE MaxCap > $c and VenueID =$id"; $result = mysql_query($sql); echo mysql_error($con); while($row = mysql_fetch_array($result)) { echo ' <input type ="radio" name="'.$row['RoomName'].'" id="'.$row['RoomID'].'" value = "'.$row['RoomID'].'" > <img src = " '.$row['Image1'],'" alt="" height="100" width="120" /> in ' . $row['RoomName'] . ' at venueID '.$id.' with capacity from '.$row['Capacity'].' to '.$row['MaxCap'].'</br> ' ; } } else { echo "Oops! Sorry, but this link seems to not be working. Please press back and try again!" ; } ?> As mentioned, the above two files have #1 & #2 working well together on same page without refresh. Now for #3...below are the independent datepicker files which work well on its own. I just can't figure out how to link the below to #1 & #2 Calendar.html <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { var selected_dates = new Array(); // get all the events from the database using AJAX selected_dates = getSelectedDates(); $('#datepicker').datepicker({ //Image: '/images/logo.png',//delete this and the next two lines (so first line showing is dateFormat to go to the way it was before. And then must change //ImageOnly: true, //showOn: 'both', dateFormat: 'yy-m-d', inline: true, beforeShowDay: function (date) { // get the current month, day and year // attention: the months count start from 0 that's why you'll need +1 to get the month right var mm = date.getMonth() + 1, dd = date.getDate(), yy = date.getFullYear(); var dt = yy + "-" + mm + "-" + dd; if(typeof selected_dates[dt] != 'undefined') { // put a special class to the dates you have events for so you can distinguish it from other ones // the "true" parameter is used so we know what are the dates that are clickable return [true, " my_class"]; } return [false, ""]; }, onSelect : function(date) { $('#date_select').val(date); $('#date_selection_container').html(date); } }); }); function getSelectedDates() { var the_selected_dates = new Array(); $.ajax( { url: 'dateselect.php', dataType: 'json', async: false, success: function(data) { $.each(data, function(n, val) { the_selected_dates[val.event_date] = val; }); } }); return the_selected_dates; } </script> </head> <body> <h3>3. Select Date</h3> <br/> <div id="datepicker"></div> <!--div id="date_selection_container"></div--> </body> </html> And finally the dateselect.php which the above calendar.html file references I fully admit I found the below on a website which uses PHP PDO which I'm not familiar with. I stuck to it though because it's working <?php session_start(); // Initializations of the variables used $dates = array(); // MYSQL connection credentials include_once "Connection.php"; // PDO - connect to the database try { $dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::ATTR_PERSISTENT, true); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } catch (PDOException $e) { echo 'Error!: ' . $e->getMessage() . '<br/>'; } // take the events from the table named "events" try { $id = (int)$_SESSION['VenueID']; //leave it as session as needed for multiple pages $room = (int)$_POST['RoomID']; $sql = ' SELECT * FROM venue_room_availability WHERE IsAvailable = "Y" and RoomID=:Room and VenueID = :Venue '; $stmt = $dbh->prepare($sql); $stmt->bindParam(':Venue',$id,PDO::PARAM_INT); $stmt->bindParam(':Room',$room,PDO::PARAM_INT); $stmt->execute(); } catch (PDOException $e) { print($e->getMessage()); die; } while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // because $row['event_date'] will have this form: 2012-01-10 and in Javascript we have 2012-1-10, // we need to rewrite it the way we use it in Javascript so we can compare it $row['event_date'] = date("Y-n-j", strtotime($row['event_date'])); $dates[] = $row; } echo json_encode($dates); ?>
  6. Hello, HartleySan - Thank you very much for your reply! Firstly, let me start by saying that the codes combine a few codes i've found on Larry's Javascript book or on the web, particularly on http://www.emirplicanic.com/javascript/jquery-ui-highlight-multiple-dates-in-jquery-datepicker. Meaning, there's probably a v good reason why it's not working and/or I won't be able to answer all of the below in a coherent manner! Here are my answers to your questions 1) Is the intended value being correctly retrieved from the DB and stored in the $row['AvailableDate'] variable? Yes, I have double checked that the Available Date variable is being retrieved correctly 2) Why are you echoing echo [ and ] before and after the $row['AvailableDate'] variable? If you are referencing the "echo '['" entries then this is where I can't give you an intelligent answer. I have seen these echo entries being used pre-post the $row when SQL SELECT is entered as part of "switch case." I've seen it as either "[" or "{", but they all seem to be used when SQL SELECT is being used. If I remove them and rewrite the "while mysql row fetch" argument in a way I'm more used to seeing, the page won't even display a datepicker. So I know they are needed, just not sure why... 3) Why are you sending the ID to the PHP script but not using it in the query? Great question -so I plan to use this ID in a "GET" function and further fine tune what mysql SELECT retrieves. In the meantime, in a lazy way, I just wanted to make sure my jquery was working so I haven't instituted that GET function yet (nor is it needed yet) and just retrieved all records from this table to see if I could get AvailalbleDate to show 4) Why are you grabbing all the records from the DB table, and then breaking the while loop after the first row that's returned, regardless of what's actually stored in the $row['AvailableDate'] variable after grabbing the first row of results from the DB? I'm grabbing all the records - -as mentioned above - for pure laziness reason for now...In terms of breaking the while loop, if you are referencing the fact that "{" and "}" is not shown after the while loop (and then including a ";" straight afterwards), then I must admit that, as mentioned on #2, I noticed this is how it was written on the URL mentioned above. I noticed too that this was breaking the while loop, so I rewrote it in the way I've seen and learned from Larry's PHP books before ..and then a blank page comes out If you could help me again as you have already done so in my other posts, I'd greatly appreciate it! Thank you!
  7. Hello -I'm trying to build a datepicker which only allows certain dates in my database to be selected.. Below are the codes...and the datepicker widget shows up but the "AvailableDate" (which is listed in the database as "2012-05-09") are not showing up in different color. Please can someone help to see where the error is? Thank you! [left]<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> <link href="css/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script> <script type = "text/javascript"> $(function(){ $.ajax({ url: "dates2.php", data: "action=showdates&id=1", dataType: "json", success: function(calendarEvents){ $(".calendarwidget").datepicker({ // [rows, columns] if you want to display multiple calendars. numberOfMonths: [1, 1], showCurrentAtPos: 0, beforeShowDay: function (date){ for (i = 0; i < calendarEvents.length; i++) { if (date.getMonth() == calendarEvents[i][0] - 1 && date.getDate() == calendarEvents[i][1] && date.getFullYear() == calendarEvents[i][2]) { //[disable/enable, class for styling appearance, tool tip] return [false,"ui-state-active","Event Name"]; } } return [true, ""];//enable all other days } }); } }); }); </script> </head> <body> <div class="calendarwidget"><!--calender widget is loaded here--> </div> </body> </html>[/left] [left] [/left] <?php [left]//DB CONFIG $hostname_logon = '***'; //Database server LOCATION $database_logon = '****'; //Database NAME $username_logon = '***'; //Database USERNAME $password_logon = '***'; //Database PASSWORD //Table config $tablename = "venue_room_availability"; //Name of the DB table $event_id = "AvailableID"; //Primary Key field of the table //Connect to the DB $connections = mysql_connect($hostname_logon, $username_logon, $password_logon) or die ('Unabale to connect to the database'); mysql_select_db($database_logon) or die ("Error in query: $qry. " . mysql_error()); /****** Bread & Butter *************/ $action = $_REQUEST['action']; switch ($action){ case 'showdates': $qry = "SELECT * FROM ".$tablename.""; $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error()); echo '['; while($row = mysql_fetch_assoc($result)); //$row['AvailableDate'] =rtrim($row['AvailableDate'], ","); echo $row['AvailableDate']; echo ']'; break; } ?>[/left] [left] [/left]
  8. WHOO HOO! Thank you very much Hartleysan and Stuart! I took all that you've suggested above and was able to FINALLY end this nightmarish problem I've been trying to resolve for days now! I actually skipped the chapter Larry had about regex in his php book but after reading your suggestion above, Hartleysan, I read it and it makes a lot of sense now. Your codes worked beautifully! Thanks so much!
  9. Hello - Thank you for your reply and help again. As you suggested in parts of your response, I decided to use php to autopopulate options and the post method (at least until I learn Ajax) to capture the value of the selected options. But now I'm stuck in a different way and, if you wouldn't mind, would appreciate your insight once more. I am building a website that lists meals and price per meal. So each meal has its own unique price. I've laid out the options below and the problem I now have is to separate the meal and price from each other when I do $_POST["menus"]. I can't seem to figure out how to separate the meal from the price as POST captures the entire selected value. Any idea? <form action="views/checktest.php" method="post" name="shopcart" id="shopcart"> <select name="menus"> <option> Select your meal here </option> <option> '.$row['meal1'].' at '.$row['meal_price1'].' </option> <option> '.$row['meal2'].' at '.$row['meal_price2'].'</option> <option> '.$row['meal3'].' at '.$row['meal_price3'].'</option> </select> <input type ="submit"/> </form> Then once submitted, checktest.php has the following codes which conjoin the price and the meal when I need them separated <p>You selected <?php echo $_POST["menus"]; ?>!</p><br /> Thank you!
  10. Thank you very much HartleySan! What you wrote out is exactly what I was looking for, except I'd appreciate your guidance on a couple of more things: 1) Rather than using javascript to autopopulate, is there a way I can use php to "fetch" data from the database to autopopulate? 2) I'm most interested in learning how the selected value can be shown in a text box - for instance, after selecting "2" under quantity, there's text box called quantity which dynamically shows "2" again. and then another text box underneath that shows selected price. And then a third box at the bottom that does "subtotal" and then shows the multiplication... Thank you so much!
  11. Hello - I would love some guidance here. The book redirects the user from sales page to a separate shopping cart page, but I'd like to create a mini same-page shopping cart page with a dynamic subtotal on the bottom of the page. More specifically, I'd like to create simple subtotal box that autopopulates quantity and price based on options the user have made. So, if a user selects quantity of "3" and then selects goods that are worth "$30", then on the same page at the bottom, it should dynamically show text as "quantity:3", "price per product: $30", and "subtotal: "$90." Here's the HTML I've been working with to select options of quantity and price. Both will have values which will dynamically be populated based on some javascript and PHP written beforehand, hence each only has one option value. I've been trying to "call" the id of each options but I can't seem to get a value or text. Thank you in advance for your help! <pre><code> <!--*define quantity--> <h3><a href="#"><b>3. Select quantity</b></a></h3> <div> <select name="quantity" id="quantity"> <option value ="">Select a Number</option> </select> </div> <!--*define product--> <h3><a href="#"><b>4. Select product</b></a></h3> <div> <select name="product" id="product"> <option value ="">Select Product</option> </select> </div> </code></pre>
  12. Thank you so much, Jonathon, again! It took me a long time, but thanks to your initial guidance, i finally figured out what I have to do to make it more dynamic and not have every single item shown with mysqli_fetchy_array. I'm sure there's some rookie mistake I'm making here, but here's what I've done for others who are looking to do the same thing On page.php, write "<?php echo '<a href="product.php?sku='.row['sku'].'">See Product 15</a>'; ?>" And then on product.php, write (after including the config and requiring MYSQL), "if (isset($_GET['SKU'])) { $sql="SELECT * FROM table WHERE table_id=".$_GET['SKU']; $result=mysqli_query ($dbc, $sql); $row=mysqli_fetch_array($result); echo ' <p> ' .$row['put a column name in the table here'] . ' </p> '; } yay! thanks! sjk
  13. Hello - Thanks for your reply. I'm quite a newbie, I actually have trouble figuring out how to "pass the SKU" over to a specific page. Is there a mysqli function that passes it over so it "catches" and recognizes just one SKU? the mysqli_fetch either gives me all the SKU or just the first one...Thanks so much! This book has really helped me get my business started Sjk
  14. Hello, In Example 2 home page, when you click ont he red mug, it takes you to a sales page with the red mug on top PLUS all these other products. I am in the process of creating my own Dynamic catalogue and would like to learn if there's a way to click on that red mug on the home page and then land on a sales page that ONLY has details of the red mug, and no other products. More specifically, the current codes on Ex 2 is as follow: 1) The red mug on the home page has the following href: <a href="/shop/sales/#' . $row['sku'] .'> 2) The above ultimately goes to a list_sales.html page with the following codes: "while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<h3 id="' . $row['sku'] . '">' . $row['category'] . '::' . $row['name'] .'</h3> <div class="img-box"> <p><img alt="' . $row['name'] . '" src="/products/' . $row['image'] . '" />' . $row['description'] . '<br />' . get_price('goodies', $row['price'], $row['sale_price']) . ' <strong>Availability:</strong> ' . get_stock_status($row['stock']) . '</p> <p><a href="/cart.php?sku=' . $row['sku'] . '&action=add" class="button">Add to Cart</a></p></div>';" 3) Is there a way to still link the home page to the list_sales.html but so that only one "SKU" or product is shown at a time? I already tried taking out the "while" loop but then it just shows the very first row even if other products are selected on the home page. I basically want so that a pix of the product the consumer selects from the home page takes them to a detailed page about that one product in a dynamic fashion... THANK YOU! sjk
  15. Hello - In Exercise 2, each coffee sales item alllows for 1 image. I am trying to move to an image gallery where each sales item will display multiple photos (one large photo with corresponding thumbnail view). I have the css template for an image gallery, but don't know how to store multiple photos per sales item in the database. Tried adding multiple photos via phpMyadmin in the general_coffees table (used commas to separate each jpg), but that did not work. Any way to do this? Many thanks in advance for your help sjk
  16. Yay! Thank you Jonathan and Stuart - It took me a while to find out which files the corrections had to be made, but the images now show up! ps - for those who are are having the same problem, corrections need to be made in the home.html and list_categories.html files (under Views Folder) Thanks again!
  17. Hello Everything is set up and working on Exercise 2 except the images won't show up - it either shows a red cross/x-mark or won't show up at all. I have all the images/logos in the right place and directory so not sure why this is happening. This is for both Firefox and IE8. Could you help? Thanks sjk
  18. Hello Stuart - Thanks. You were right - I was overthinking it. Not only was the syntax incorrect but due to a "Start date" that was set in the future for some reason, the table was empty. Thanks so much!
  19. Thanks, Stuart Here's when I echo out the mysqli_error: "Unknown column 'sv.venue_id' in 'on clause'" Not sure which query I should post here, but here's a couple 1) Query in the home.html if (mysqli_num_rows($r) > 0) { echo '<dl class="special fright"> <dt><a href="/shop/sales/">Sale Items</a></dt>'; // Fetch each item: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<dd><a href="/shop/sales/#' . $row['sku'] . '" title="View This Product"><img alt="" src="/products/' . $row['image'] . '" /><span>' . $row['sale_price'] . '</span></a></dd>'; } echo '</dl>'; 2) the stored procedure query index.php is trying to reference to return some rowsCREATE PROCEDURE select_sale_items (get_all BOOLEAN) BEGIN IF get_all = 1 THEN SELECT CONCAT("O", nvp.id) AS sku, sa.price AS sale_price, nvc.category, nvp.image, nvp.name, nvp.price, nvp.stock, nvp.description FROM sales AS sa INNER JOIN non_venue_products AS nvp ON sa.product_id=nvp.id INNER JOIN non_venue_categories AS nvc ON nvc.id=nvp.non_venue_category_id WHERE sa.product_type="other" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) ) UNION SELECT CONCAT("v", sv.id), sa.price, gv.category, gv.image, CONCAT_WS(" - ", s.size, sv.meal, sv.drinks), sv.price, sv.stock, gv.description FROM sales AS sa INNER JOIN specific_venues AS sv ON sa.product_id=sv.id INNER JOIN sizes AS s ON s.id=sv.size_id INNER JOIN general_venues AS gv ON gv.id=sv.general_venue_id WHERE sa.product_type="venue" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) ); ELSE (SELECT CONCAT("O", nvp.id) AS sku, sa.price AS sale_price, nvc.category, nvp.image, nvp.name FROM sales AS sa INNER JOIN non_venue_products AS nvp ON sa.product_id=nvp.id INNER JOIN non_venue_categories AS nvc ON nvc.id=nvp.non_venue_category_id WHERE sa.product_type="other" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) ) ORDER BY RAND() LIMIT 2) UNION (SELECT CONCAT("v", sv.id), sa.price, gv.category, gv.image, CONCAT_WS(" - ", s.size, sv.meal, sv.drinks) FROM sales AS sa INNER JOIN specific_venues AS sv ON sa.product_id=sv.id INNER JOIN sizes AS s ON s.id=sv.size_id INNER JOIN general_venues AS gv ON gv.id=sv.venue_id WHERE sa.product_type="venue" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) ) ORDER BY RAND() LIMIT 2); END IF; END$$ DELIMITER ;
  20. Hello, I'm at the end of chapter 8 of your Effortless book and keep getting the following error message when I open up my site. The line 15 in home.html referenced below is the following : >> if (mysqli_num_rows($r) > 0) {Could you please help?. I've double checked all the files and the stored procedure in index.php does return some rows, so not sure why this is not working An error occurred in script '\xxx\html\views\home.html' on line 15: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array ( [0] => Array ( [function] => my_error_handler [args] => Array ( [0] => 2 [1] => mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given [2] => xxx\html\views\home.html [3] => 15 [4] => Array ..and so on.
×
×
  • Create New...