Jump to content

JackW

Members
  • Content Count

    31
  • Joined

  • Last visited

Community Reputation

0 Neutral

About JackW

  • Rank
    Newbie
  • Birthday 10/18/1946

Contact Methods

  • Website URL
    http://www.panhandleyardsale.com/
  1. JackW

    Query two tables?

    I think I need to put a second query in the loop. I had the below code in a previous version of php and it worked fine. Can't seem to make it work now in the updated version. What do I need to do differently? The below code only gets one line from the first table and non from the second table. <?php $db = @mysqli_connect('localhost', 'unsabook', 'Yearbook#1964', 'unsabook'); if (!$db) { echo "Error: " . mysqli_connect_error(); exit(); } $rs_message = $db->query ("SELECT * FROM `messages` ORDER BY `message_ID` DESC LIMIT 0,200"); while ( $message_array = $rs_message->fetch_assoc() ) { echo '<div>'; echo $message_array['message_ID']; echo 'Subject: <b>'; echo $message_array['subject']; echo '</b>'; echo ' Submitted by '; echo $message_array['name']; echo '<br>'; echo $message_array['message']; echo '<br></div>'; $rs_replies = mysql_query("SELECT * FROM replies WHERE message_ID = '" . $message_array['message_ID'] . "' ORDER BY `reply_ID` DESC"); while($replies_array = mysql_fetch_assoc($rs_replies)) { echo '<div class="indent">'; echo $replies_array['reply_ID']; echo '<b>Reply</b> '; echo 'Submitted by '; echo $replies_array['name']; echo '<br>'; echo $replies_array['message']; echo '</div>'; } } $db->close(); ?>
  2. JackW

    Query two tables?

    I have a MySQL data base with two tables. I need to query the second table to find related results from a query on the first table. Here is what I have, How do I get it to combine the two queries? <?php $db = @mysqli_connect('localhost', 'unsabook', 'Password', 'unsabook'); if (!$db) { echo "Error: " . mysqli_connect_error(); exit(); } $rs_message = $db->query ("SELECT * FROM `messages` ORDER BY `message_ID` ASC LIMIT 0,200"); while ( $message_array = $rs_message->fetch_assoc() ) { echo '<div class="left10">'; echo $message_array['message_ID']; echo ' &nbsp; '; echo $message_array['school']; echo ' &nbsp; '; echo $message_array['name']; echo ' &nbsp; '; echo $message_array['post_day']; echo ' &nbsp; '; echo $message_array['reply_day']; echo ' &nbsp; '; echo $message_array['subject']; echo ' &nbsp; '; echo $message_array['message']; //$message_ID = $message_array['message_ID']; echo '</div>'; } // 2nd table is below $rs_replies = $db->query ("SELECT * FROM `replies` WHERE `message_ID` = '".$message_ID."' ORDER BY `reply_ID` DESC"); while($reply_array = mysqli_fetch_assoc($rs_replies)) { echo '<div class="left10">'; echo $reply_array['reply_ID']; echo ' &nbsp; '; echo $reply_array['name']; echo ' &nbsp; '; echo $reply_array['message_ID']; echo ' &nbsp; '; echo $reply_array['reply_day']; echo ' &nbsp; '; echo $reply_array['message']; echo '</div>'; } $db->close(); ?>
  3. Thank you so much for your help. Jack
  4. Thank you. That is probably the problem. Some of the arrays contain only a single element while others have two elements separated by "|". Those that contain 2 elements need to be separated. How would I write it to use isset()?
  5. I will try to be short. I am getting a Notice about the code below. " Notice: Undefined offset: 1 " it refers to the last line of the code below. That code worked for 3 years and I changed nothing, now for some reason I am getting the notice. Can you help? $total_type=($row ['type1'] ); $typeChunks = (explode("|", $total_type,2)); $type2 = ($typeChunks[0]); $type_link = ($typeChunks[1]);
  6. Thank you!! I have been the most of two days trying to figure that out. Now to incorporate it into the form on the actual page. Below is the code that worked. $i = 1; // Initialize $i outside the loop echo '<table class="one" width="500" border="0" cellpadding="0" cellspacing="0" align="center">'; $resource = $db->query("SELECT * FROM `outside_levy` WHERE `budget_year` = '".$budget_year2."' AND `department` != '".$blank."' AND `levy_type` != '".$tax_credit."' AND `levy_type` != '".$tax_credit_ag."' ORDER BY `rank` ASC, `levy_type` ASC, `department` ASC LIMIT 0, 40"); while ($row = $resource->fetch_assoc() ) { echo '<tr><td width="90%">'; echo '<div class="levy2">'; echo $i++; echo '<b>'; $tax=number_format(($row ['levy'] )*$value2, 2); echo ' &nbsp; '; echo ($row ['department'] ); echo '</b></div>'; echo '</td><td width="10%"><div class="rightblack">'; echo $tax; echo '</div>'; echo '</td></tr>'; }
  7. I am updating a website to php7 from php5. The project was going well until I come to this page. The page actually uses a form to transfer information to the next page with the checkboxs numbered as ($i+1). The code below in not the form but I "think" that if I can get that code to work I can make the form work. I need to place 1, 2, 3, etc in the result from the php7. when I leave out (for ($i=0; $i < $match_results; $i++)) and (echo ($i+1);) the rest works fine but my form boxes are not numbered so will not transfer to the next page. The link below is the page that works with php5 with the checkbox form on the right. http://www.sheridancountyne.com/levy_page.php?year=2017&amp;value=56000 The below code works with php5 <html> <body> <?php require ("$path/require/connect.php"); $budget_year2=("2017"); $tax_credit=("Tax Credit"); $tax_credit_ag=("Tax Credit Ag"); $show=("show"); $base=("Base"); $value2=("50000"); echo '<table class="one" width="500" border="0" cellpadding="0" cellspacing="0" align="center">'; $query= ("SELECT * FROM `outside_levy` WHERE `budget_year` = '".$budget_year2."' AND `department` != '".$blank."' AND `levy_type` != '".$tax_credit."' AND `levy_type` != '".$tax_credit_ag."' ORDER BY `rank` ASC, `levy_type` ASC, `department` ASC LIMIT 0, 40"); $query_results=mysql_query($query); $match_results=mysql_num_rows($query_results); for ($i=0; $i < $match_results; $i++) { $row=mysql_fetch_array($query_results); echo '<tr><td width="90%">'; echo '<div class="levy2"><b>'; $tax=number_format(($row ['levy'] )*$value2, 2); echo ($i+1); echo ' &nbsp; '; echo ($row ['department'] ); echo '</b></div>'; echo '</td><td width="10%"><div class="rightblack">'; echo $tax; echo '</div>'; echo '</td></tr>'; } echo '</table>'; mysql_close($db); ?> </body> </html> I need to place the code for ($i=0; $i < $match_results; $i++) and echo ($i+1); in the new code for php7 below. <html> <body> <?php require ("$path/require/connectphp7.php"); $budget_year2=("2017"); $tax_credit=("Tax Credit"); $tax_credit_ag=("Tax Credit Ag"); $show=("show"); $base=("Base"); $value2=("50000"); echo '<table class="one" width="500" border="0" cellpadding="0" cellspacing="0" align="center">'; $resource = $db->query("SELECT * FROM `outside_levy` WHERE `budget_year` = '".$budget_year2."' AND `department` != '".$blank."' AND `levy_type` != '".$tax_credit."' AND `levy_type` != '".$tax_credit_ag."' ORDER BY `rank` ASC, `levy_type` ASC, `department` ASC LIMIT 0, 40"); while ($row = $resource->fetch_assoc() ) for ($i=0; $i < $match_results; $i++) // this does not work here in php7 how do I write a code that will work with (Si+1) below { echo '<tr><td width="90%">'; echo '<div class="levy2"><b>'; $tax=number_format(($row ['levy'] )*$value2, 2); echo ($i+1); //this is the part that will not work in php7 echo ' &nbsp; '; echo ($row ['department'] ); echo '</b></div>'; echo '</td><td width="10%"><div class="rightblack">'; echo $tax; echo '</div>'; echo '</td></tr>'; } echo '</table>'; $db->close(); ?> </body> </html>
  8. I have a website that has worked fine for several years. It uses php and a mysql data base. I can still make changes to the data base, but have a hard time getting the new text to show up. It is changed in the data base but the browser insists on showing a cached copy. In the past it worked fine. Don't know what changed. I also use a cookie set by a user name and password and now when I click on the log out function, I need to refresh the log out page before it logs me out. I have looked for a method to disable the cache but nothing I have found works. The site is on a Windows server, not by my choice. Any ideas?
  9. Thank you, I believe I can work with that and it will do just what I want it to do. JackW
  10. Thanks, I may be able to make that work. What I really need is just a simple piece of code that does the link part provided in the rich text editor. That may well not be something that is available. JackW
  11. I am developing a website where my client can update the text using simple forms. I have developed several such site using php and a MySQL database. My current client wants to have the ability to add links within the text without typing the full link code. The form I am using to post this question has the function I need. A box pops up where one can put in the url and form a link. Can someone tell me how to create that function for my page?
  12. Thank you! Thank you! Thank you! That Worked! I can't believe the number of hours I spent trying to find the answer because I was too stuborn to ask for help.Have a Merry ChristmasJackW
  13. I have several sites on Linux servers where I have set it up so the site owner can upload picture files. Below is a simplified version of the code used. (without security features that are on the real sites.)Now I have a client that would like this feature on his site, but it is hosted on a windows server. The code does not work on his site.Html form Page code: <body><form enctype="multipart/form-data" action="upload.php" method="POST">Please choose a file: <input name="uploaded" type="file" /><br /><input type="submit" value="Upload" /></form></body> Php page code: <body><?php$target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";} else {echo "Sorry, there was a problem uploading your file.";}?></body> The html code is in a folder named test. That same folder named test contains a folder named upload. I set up the windows hosted site and one of my linux hosted sites exactly the same. On the linux server I get this message: “The file 100_0095.jpg has been uploaded” and the file is in the folder.On the windows server, no file in folder, and I get this message:“Warning: move_uploaded_file(upload/100_0095.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\5310323\html\test\upload.php on line 19Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php6435.tmp' to 'upload/100_0095.jpg' in D:\Hosting\5310323\html\test\upload.php on line 19Sorry, there was a problem uploading your file.”I have been looking for solutions and trying different things for 2 days. What am I doing wrong.Some one suggested it was a CHMOD problem. That is not the case on Linux. I don't have a clue about permissions on Windows. This is my first and I hope last experience with a windows server.Thank you for any help you can give.Is it possible to upload files to windows servers and how is it done?
  14. JackW

    Php Require Question

    Thanks, I will play with it some more. Just knowing that it should work helps a lot. Maybe I have some brackets in the wrong place.
  15. JackW

    Php Require Question

    Thank you and please do not spend a lot of time here as copy and paste will work.I will try to explain what I am trying to do.I have a data base with 3 tables. One contains product information. Item name, number, and price.One contains customer information. Customer Number, City, State, County.One contains tax rates for the City, State, and County where my client is required to collect sales tax when shipped to that City, State, and County.From the product table I can create variables for the product informationI can connect to the data base and with the Customer Number get the City State and County. Take that information to the tax rate tables and get the City, County and State tax rates and add those three to come up with a tax rate for the sale.Those variables then need to be placed in the shopping cart button form. This shopping cart button form is what I would like to insert with the require function. See the sample code.<?phpecho '<form target="cart" action="https://www.cart_URL" method="post"><input type="hidden" name="business" value="Bussiness_Code"><input type="hidden" name="item_name" value="';echo $title;echo '"><input type="hidden" name="item_number" value="';echo $stocknumber;echo '"><input type="hidden" name="amount" value="';echo $cost;echo '">';echo '<input type="hidden" name="tax_rate" value="'echo $tax_rate;echo '">';echo '<input type="hidden" name="add" value="1"><input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_SM.gif:NonHosted"><input type="image" src="cart_button" border="0" name="submit" alt="Add to Cart Button"><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>';?> When I use the php opening and closing, it doesn't let me use the variables I have created.When I do not use the php opening and closing it writes it as html and of course doesn't let me insert the variables I have created.I can copy and paste the code (without the open php and close php) in each place it is needed and it will work. Note: I did remove some lines from the total button code so it may contain errors that are not in the complete code.Thanks again for your help.
×
×
  • Create New...