Jump to content

dragon2309

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

dragon2309's Achievements

Member

Member (2/5)

0

Reputation

  1. Okay, now fixed thanks to the advice from Jessica. Many thanks, I'll look into modulo now Thankyou! Dave
  2. Hi Jessica, thanks for your reply I've not heard of or used modulo, I'll look into that for an upgrade later on, for now I need this working at least to some extent. Are you saying I need to add the record echoing code into the else statement aswell??
  3. Small update, the code is clearly bugged, as it does the same thign on the other pages, I was just being dim.... It misses the 4th record from every line. So its not echoing records 4, 8, 12 etc..
  4. Hey there everyone, I've been playing with PHP and SQL for a few years, mainly as a hobby, so I'm not an expert, and it takes me a while to get most things working. This has me stumped... I'm pretty sure (like 80% sure) that it was working fine, then I just noticed the bug and have no idea how to fix it.. I run an SQL query, that when run in the db returns 6 records, all 6 records are to be echoed to the page as per this loop: $i = 1; while ($row = $result->fetch()) { if ($i <= 3) { $output[] = '<div id="featuredinner">'; $output[] = "\n"; $output[] = '<a href="images/'.$row['img'].'_lrg.jpg" rel="lightbox" title="'.$row['desc'].'"><img src="images/'.$row['img'].'_lrg.jpg" width=150px /></a><br />'."\n".' '.$row['title'].' - <strong>£'.$row['price'].'</strong><br /> <a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a>'; $output[] = "</div>\n "; } else { $output[] = '<br /><br /><br />'; $i = 0; } $i++; } I use the same loops on multiple other pages echoing records from the same table (just with different credentials) and they seem to be workign fine. It's jsut this one.. The bug is that the 4th record is never returned, 1, 2 and 3 are echoed on one line as desired, then its ment to drop a line and echo 4, 5 and 6, it doesnt, all i get is 5 and 6 and then a blank space. Ideas?? As said the exact same piece of code for the loop and if statement is used on other pages (different product categroies) perfectly, the only difference is that the other sections have more items in, (some have 18-19 things in that are echoed on page 3 per line perfectly fine.. Page is live at http://www.thechocolatehut.co.uk/truf_milk.php if you want to see, ignore the DQL query being echoed to apge, I wanted to see what query the page was generating. Thanks all, Dave.
  5. Hi, im honestly not that dumb in real life honest!! Lol. I swear i uploaded the complete images folder to that directory several times... Christ knows where i was actually putting it, its been a long few days. You are correct there is nothign wrong with my php at all, it all works sound. Pages are now being displayed correctly, many thanks for pointing out my epic fail there. Dave
  6. Okay, PHP is below, just wondered if it might have been a known issue that was common or had been heard of and diagnosed before. Heres the PHP: <?php // MySQL class require_once('inc/mysql.class.php'); // database connection require_once('inc/global.inc.php'); // functions require_once('inc/functions.inc.php'); // start session session_start(); echo"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <script type='text/javascript' src='iepngfix_tilebg.js'></script> <script type='text/javascript' src='js/prototype.js'></script> <script type='text/javascript' src='js/scriptaculous.js?load=effects,builder'></script> <script type='text/javascript' src='js/lightbox.js'></script> <link rel='shortcut icon' href='favicon.ico' /> <link rel='stylesheet' media='screen' type='text/css' href='style1.css' /> <title>The Chocolate Hut</title> </head>; <body> <div id='container'> <a href='index.htm'> <div id='header'> </div> </a> <div id='menucontainter'> <div id='menuleftpad'> </div> <div id='menuleftgrad'> </div> <a href='index.htm'> <div id='menuhome'> </div> </a><a href='products.htm'> <div id='menuyummy'> </div> </a><a href='find.htm'> <div id='menufind'> </div> </a><a href='contact.htm'> <div id='menuspeak'> </div> </a> <div id='menurightgrad'> </div> <div id='menurightpad'> </div> </div> <div id='contentleftpad'> </div> <div id='contentleftgrad'> </div> <div id='contentmain'> <p class='contentbodycentre'> <div id='shoppingcart'> <h1>Your Shopping Cart</h1>"; echo writeShoppingCart(); echo"</div> <div id='booklist'> <h1>The Chocolate Huts Stock</h1>"; $sql = 'SELECT * FROM chocstock ORDER BY id'; $result = $db->query($sql); $output[] = '<ul>'; while ($row = $result->fetch()) { $output[] = '<li>'.$row['title'].' :: £'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>'; } $output[] = '</ul>'; echo join('',$output); echo"</div> </p> </div> <div id='contentrightgrad'> </div> <div id='contentrightpad'> </div> <div id='footerleftpad'> </div> <div id='footermain'> </div> <div id='footerrightpad'> </div> </div> <br /> <p class='footer'>Design and Style - Dave Byrne (C)2011</p> <br /> </body> </html>";
  7. Hi all, wasn't sure if this should be in PHP or in CSS, but as the page works fine without the PHP, i figured the issue must be there. Basically, i have a site designed, all running fine. I'm in the process of adding a basket system into it. The cart itself works fine aswell on its own. My pages are made up of a matrix of div layers, all styled and arranged using CSS, the design for the page is built by using the DIV layers and assigning them background images through CSS. Now, when i transpose the PHP elements of the basket system onto a template page of the site design, the design disappears.. The DIV's retain their positioning data and their size/layer positions, so the basket content is phyisically held and positioned correctly, but EVERYTHING involving an image (even the site background) is missing. I've tried a few things but i cant seem to get the images to return. I tried echoing the whole html page out as PHP, the result was exactly the same. The page renders fine if i take out all the PHP. Any ideas? The page concerned is www.thechocolatehut.co.uk/cart2 If you need to see the PHP then let me know and i'll post it up. Dave
  8. sweet, nice and simple, thankyou rhodesa, saved a lot of time there. regards, dave
  9. Hi all, wonder if you can help me. To cut a long story short, I am attempting to paginate my mysql results by using the "limit" clause in an SQL query, but i want the number of results per page to be able to be set by the user. The way I want to go about this may mean that at times the user hasnt selected anything, so I need a way to be able to embed a default value in a PHP $_GET function if there has been no user input, and of course for this value to be ignored if the user has expressed they want it to be different than the default (say 10 records per page) Any ideas, I'm fairly open to changing my tactics, as long as it makes sense in my head I can usually work at it, so bring your ideas. Cheers in advance, Dave
  10. ok, yeh, server is messing about at the moment, i checke the source, and your right, the contents of menu.htm ARE NOT in the cell, it is simply shoved at the bottom of the code when index.php finishes.... which is strange.... how do i get it to actually shove all of menu.htm INTO THE CELL, and not just ina seemingly random place... cheers, dragon
  11. ok, below is the code for my whole index.php page, you can see the tiny PHP block midway down in a cell - [code]<html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>CamberCaravan.co.uk</title> </head> <body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <p></p> <div align="center">     <table border="0" width="60%" id="table1" style="border-collapse: collapse" height="684">         <tr>             <td colspan="2" height="202"> <img src="img/mainhead1.jpg" width="800" height="200"></td>         </tr>         <tr>             <td width="24%" height="90%"><?php include("menu.htm"); ?></php></td>             <td width="76%" height="90%">&nbsp;</td>         </tr>     </table> </div> </body> </html>[/code] I cant see how else i would have to code it, surely it should be putting the menu inside that table cell??? if you want to see a live version then go to [a href=\"http://www.cambercaravan.co.uk\" target=\"_blank\"]http://www.cambercaravan.co.uk[/a] cheers, dragon [b][u]*EDIT* - server is experiencing downtime, sorry, site unavailable[/u][/b]
  12. Hi, i have a .htm file whihc contains SCRIPT src links to a javascript menu, this file is called menu.htm... On my index.php file i have a general layout set up using tables. In one of the table cells i have entered <?php include("menu.htm"); ?> This works fine, the menu gets displayed on the index.php file, only one problem, the menu gets displayed as it nwould do on the menu.htm file, theis means its butted up against the left hand side of the window, even though i put the INCLUDE function into the table cell, what i wanted it to do is shove the mune into the table cell (obviously it doesnt work like that)... So my question, is there any alternative to the INCLUDE function... or is there some parameter im missing?? Sorry, this probably sounds really n00bish, lol. Any help given is much apreciated. dragon
  13. hey hey everyone, how you all doing. First post here so go easy please. Heres the problem. [!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--][b][u]Background Info:[/u][/b][!--sizec--][/span][!--/sizec--] I have been progresing through this project to get user customisable queries, as in i want the user to be able to specify a price etc... and all records that muatch get returned. Simple.... yeh.... well i got that far, and it worked. [!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--][b] [u]The Problem:[/b][/u] [!--sizec--][/span][!--/sizec--] I want to call records from about 12 different tables. if i do this in the usual way "SELECT * FROM table1, table2, table3" and so on, i get an error saying &price was ambiguous. $price being the variable the user selects to filter the records by. Heres the code ive got, i dont know why it is coming up with this error.... [code]<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>price Query</title> </head> <body> </head> <body>    <h1>price Query</h1>       <form id="make_select" action="<?php $PHP_SELF; ?>" method="post">    <p>      Select price:      <select name="price">        <option value="£1.99">£1.99</option>        <option value="£2.99">£2.99</option>        <option value="£3.99">£3.99</option>      </select>      <input type="submit" />    </p>    </form>    <br>    <?php      if( ! empty( $_POST["price"] ) )      {        echo '<table border="1" bgcolor="#FFD9FF" bordercolor="#FF9DFF" bordercolorlight="#FF9DFF" bordercolordark="#FF9DFF" cellpadding="6" style="border-collapse: collapse; font-family: Tahoma; font-size: 11pt">      <tr>        <th><font face="Tahoma">Item Number</font></th>        <th><font face="Tahoma">Description</font></th>        <th><font face="Tahoma">Price</font></th>        <th><font face="Tahoma">Image</font></th>        <th><font face="Tahoma">Information</font></th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th>Item Number</th>        <th>Description</th>        <th>Price</th>        <th>Image</th>        <th>Information</th>      </tr>     </div>      <tr>        <td bgcolor="#FFECFF">&nbsp;</td>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>        <th bgcolor="#FFECFF">&nbsp;</th>      </tr>';        require "dbinfo.php";        // Connect to MySQL DBMS        if (!($connection = @ mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD)))          showerror();        // Use the cars database        if (!mysql_select_db(DB_DATABASENAME, $connection))          showerror();        // Create SQL statement        $price = $_POST["price"];        $query = "SELECT * FROM ad_brac, ch_brac, ad_neck WHERE Price='$price' AND StockCount > 0";        // Execute SQL statement        if (!($result = @ mysql_query ($query, $connection)))          showerror(); // starts counter at 0        $counter=-1;     while ($row = @ mysql_fetch_array($result))        {        if($counter == 2){//this will tell us we already have 2 items in the row so start a new row         echo "</tr>";//close the old row         $counter=0; //reset the counter as we will now be starting a new row         echo "<tr>";//start a new row     }          if ($counter == -1) {         //this code will only action on the first time through, after that counter will hold values on 0,1,or 2         $counter=0; //reset the counter to begin         echo "<tr>";//start the first row of the results     }         if($counter < 2){ //if we already have 2 items in the row then we need to start a new row                         echo "<td>{$row['StockCode']}</td>                <td>{$row['Description']}</td>                <td>{$row['Price']}</td>                <td><p><a href='{$row['IMGURL']}'><img src='{$row['IMG']}'></img></p></td>                <td><center>{$row['URL']}</center></td>";         if ($counter == 0) echo '<td bgcolor="#FFECFF">&nbsp;&nbsp;&nbsp;&nbsp;</td>'; //do this to ensure a nice space between the two coloumn              $counter++; //increment the counter to show we have added one item to the current row     }     }//end of while loop          //so now we are out of the while loop, we need to assess how the table ended. how many items are in the last row     //if there is only one then we need to flesh out the second item in that row is &nbsp; to make it look good     if ($counter==1){     echo "    <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>";     }                     echo "</td></table>";        }               if($counter == -1)         echo "<br><br><font face='Tahoma' style='font-size: 11pt'>We're sorry, simplyTrue currently do not have any items of jewellery in stock that meet your criteria. Please try your search again or use the <a href='http://www.simplytrue.co.uk/customnotes.htm'><b>Custom Jewellery</b></a> link to request a specific item of jewellery.<br><br>Thankyou, simplyTrue.</font>";      ?> </body> </html>[/code] The page is located at [a href=\"http://www.simplytrue.co.uk/stocklist/query_new.php\" target=\"_blank\"]http://www.simplytrue.co.uk/stocklist/query_new.php[/a] Please help me, i am at a loss as to what to do... Thankyou, [b]dragon2309[/b]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.