Jump to content

RynMan

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Everything posted by RynMan

  1. RynMan

    HTML Forms

    Hi guys I've basically got a form, and I'd like it to email the results to my email. Though I'd like it to be formatted and layed out a particular way using html. Am I dreaming? Is this possible? Any third party applications that might recommend? Thanks for any help!
  2. Hi Guys I've constructed a modified shopping cart system using the tutorial here: http://v3.thewatchmakerproject.com/journal/276/ I'm not great at PHP but have managed to have it working great. My question is: How can I send the data stored in my session, via email using the form? On the final page before the submission is made to email the data - i've got contact detail inputs for the form, and the cart items shown. I just don't know how to send that info onwards. Many thanks....
  3. Ah yep, sorry! $QueryData = mysql_query("SELECT * FROM `Items` WHERE ItemCategoryShort = '$ItemCategory' ORDER BY UnitPrice ASC", $connection); if (!$QueryData) { die("Database query failed" . mysql_error()) ; } $ArrayData = mysql_fetch_array($QueryData);
  4. Hey guys I'm not amazing at PHP, but know just enough to be dangerous. Basically I'm trying to get these records from my database to display in rows of 4. For some reason every time, I'm missing a record (the first record returned in my query). It's probably something simple is my code. Would be grateful if anyone could lend a suggestion. <?php $a=0; $b=3; while ($ArrayData = mysql_fetch_array($QueryData)) { //if a=0, start new row if ($a==0) { echo '<tr>'; } //create cell //if thumbnail exists, use it, otherwise throw in the unavailable image if ($ArrayData["PhotoThumb"]!="") { $ImageToUse = $ArrayData["PhotoThumb"]; } else { $ImageToUse = "image_unavailable_thumb.jpg"; } echo ' <td width="33%" align="center" valign="top"><p><a href="item.php?ItemID='.$ArrayData["ItemID"].'"><img src="images/'.$ImageToUse.'" border="0" /></a></p> <p><a href="item.php?ItemID='.$ArrayData["ItemID"].'" class="cart_body_text">'.$ArrayData["ItemName"].'</a><br /> <span class="style1"> <strong>$'.sprintf("%01.2f", $ArrayData["UnitPrice"]).'</strong></span><br /> </p> </td>'; //increment by 1 $a++; //if a = 3 then close the row using </tr>, ready to start a new one if ($a==$b) { echo ' </tr>'; //reset counter, ready to start new row $a=0; } } if ($a > 0 ) { echo '</tr>'; } ?> Thanks guys!
  5. Hey guys! I'm trying to work through my shopping cart here and am having a problem. Everytime I start up a new session (clear my cookies in firefox) and start testing, I get the following error.... Notice: Undefined variable: cart in C:\wamp\www\Adept\action_handle.inc.php on line 16 It's pointing to my code here.... session_start(); $cart = $_SESSION['cart']; $action = $_GET['action']; $iquantity = $_POST['iquantity']; I'm guessing it's because the session has just started so naturally there will be nothing in the 'cart'. How is this usually avoided? Do we need to assign something to the cart to start with? I'm trying not to do that, as my cart counts the number of instances a number (ID) appears....so I can't really have any values in there to start. Thanks for any help!
  6. If someone else had any ideas id be extremely grateful.
  7. That site seems to be down right now. The same tutorial is posted here: http://www.studyblog.net/2008/11/a-simple-php-shopping-cart-script/
  8. What do you think? Where do you define $db - if anywhere? Well....that's my question. Is it defined somewhere that I'm missing? I can't see it defined anywhere in my code, nor the code the poster on that page has written, however that means very little (as I said I was a PHP novice).
  9. Hi guys I'm basically trying to implement this cart into my pages: http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart I understand it for the mostpart (I'm a novice at PHP but can generally figure out what's going on here). When I run this code on my cart display page I get the following error: <?php function showCart() { $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart_add.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM Items WHERE ItemID = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart_add.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$ItemName.' by '.$author.'</td>'; $output[] = '<td>£'.$UnitPrice.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>£'.($UnitPrice * $qty).'</td>'; $total += $UnitPrice * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: £'.$total.'</p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } showCart(); ?> Notice: Undefined variable: db in C:\wamp\www\Adept\cart_add.php on line 88 Fatal error: Call to a member function query() on a non-object in C:\wamp\www\Adept\cart_add.php on line 88 Line 88 is pointing to this line of code $result = $db->query($sql); I realise that $db isn't defined....but should it be? I think I'm missing something here. I looked through all of the poster's code and nowhere does he define that variable....maybe the function isn't returning anything? Thanks for any help guys.
  10. Thanks PFM! A little too late here, can't believe I missed that one.
  11. Hi guys I've got a set of records pulled via my query. The three fields are the year a production occurred, the name of the production, and the role the person played in it. I basically want to display it like this 2009 Romeo and Juliet - Romeo Walking Tall - John 2008 Another production - role Some other production - role Here's my code... $Year = 0; while($DataArray = mysql_fetch_array($dataquery)) { if ($Year != $DataArray["Year"]) { echo $DataArray["Year"]."<br />". $DataArray["Production"]." ".$DataArray["Role"]."<br />"; $Year = $DataArray["Year"]; } else { $DataArray["Production"]." - ".$DataArray["Role"]."<br />"; $Year = $DataArray["Year"]; } } So I'm basically trying to have it look at my year, and if it is the same as the previous record's year, create just the line without the year. It's not actually peforming my 'else' part of my if statement. What am I missing?
  12. Hi guys I'm struggling a little with the concept arrays, not sure why this doesn't work. I have this code: $result9 = mysql_query("SELECT * FROM `tblclientinformation` LEFT JOIN tblphotos ON tblclientinformation.KAMClientID = tblphotos.KAMClientID WHERE Current = 1 AND Gender='$Gender' AND Actor=TRUE $LocationQ ORDER BY LastName LIMIT $RecordNumber, $RecordsOnPage", $connection); if (!$result9) { die("Database query failed" . mysql_error()) ; } Then later on down the page I want to use it like this.... while ($row9 = mysql_fetch_array($result9)) { echo '<td width="125" align="center"><a class="actorsListLink" href="cvprofile.php?ID='.$row9["KAMClientID"].'"><img src="headshot/ListHeadShot/'.$ListHeadShot.'" border="0" width="72" height="90" /><br />'.$row9["FirstName"]."<br />".$row9["LastName"].'<br />'.$row9["KAMClientID"].'</a></td>'; } Everything echos here except "KAMClientID". The first and last names work fine, but the ID does not. I've done a print_r for my array and it is in there as the first item in the array [0]. When I substitute the "KAMClientID" for zero, it works perfectly. Why do my other accept the text, however this one does not?
  13. I have a lot of code, and I realise when ppl post every line of code they have, it deters other from taking a look at their problem. In this case, I made a mistake and apologised for it. Thanks for your understanding.
  14. My apologies PFM. I found this code also occurring in there.... $arrayWriters = mysql_fetch_array($resultWriters) ; This was the cause. Thanks for your help.
  15. Hi guys So I'm trying to display some text from mySQL but it's only showing one of the two records in the database. Here's my code.... $resultWriters = mysql_query("SELECT * FROM `tblclientinformation` WHERE Fight = 1 ORDER BY LastName ASC ; ", $connection); if (!$resultWriters) { die("Database query failed" . mysql_error()) ; } while ($arrayWriters = mysql_fetch_array($resultWriters)){ echo ' <tr> <td> </td> <td><span class="FieldText14"> <a href="cvprofile_other.php?CVType=director&KamID='.$arrayWriters["KAMClientID"].'">' .$arrayWriters["FirstName"]." ".$arrayWriters["LastName"].'</span></a></td> <td> </td> </tr> '; } Any idea why it's only displaying one of the two records returned in my query?
  16. Hi guys Here's my code: <?php foreach ($LNames as $val) { echo "it=s2.addItem(5,6,7,'$val',n,n,'','',n,n,n,n,n,112,20,2,0,0);\n"; } ?> What I also want to do here, is have another variable adding values from another array. Here's essentially what I want to do, but the code isn't correct..... <?php foreach ($LNames as $val and $LinkNumber as $link) { echo "it=s2.addItem(5,6,7,'$val',n,n,'$link','$link',n,n,n,n,n,112,20,2,0,0);\n"; } ?> In the earlier code, I have a loop assigning different values to an aray for $LNames. At the same time, I'm adding values to the $LinkNumber array of the same integer. So then, what I'm trying to do above, is have the following in my echo... $LNames[0] along with $LinkNumber[0] $LNames[1] along with $LinkNumber[1] $LNames[2] along with $LinkNumber[2] and so on...... Thanks for any help guys
  17. thanks for the help guys. works great.
  18. <?php foreach ($LNames as $val) { echo 'it=s2.addItem(5,6,7,"'.$val.'",n,n,"","",n,n,n,n,n,112,20,2,0,0);\n'; } ?>
  19. I should also note that in place of "John Smith" I'm actually using a variable with an array with multiple values. Just put the text in for the purpose of explaining it as it still has the same result.
  20. Thanks Thorpe. I'm trying to basically echo this in my PHP document, amongst some other javascript. echo 'it=s2.addItem(5,6,7,"'John Smith'",n,n,"","",n,n,n,n,n,112,20,2,0,0);'; However it is killing my javascript on the page. Nothing appears. Though, when I do this.... it=s2.addItem(5,6,7,"<?php echo "John Smith"; ?>",n,n,"","",n,n,n,n,n,112,20,2,0,0);\n'; it works fine.
  21. Thanks! Then how would I basically get it to echo the contents until it was empty? i.e. if there were 5 items in the array....have it do.... echo $Item[0]; echo $Item[1]; echo $Item[2]; echo $Item[3]; echo $Item[4]; without having to have the code for each array? For example if my array size is always changing, I just want to echo what is there....
  22. Hi guys I have some code performing a loop. What I'd like, is for some of the particular values I get during my loop, to be stored in an array so I can access them later on the page. How can I basically say 'on each loop, add this value to an array' ? Many thanks!
  23. Hey guys I've got a menu built using a third party tool and it has effectively created all of the javascript which is nice. What I'm trying to do is have the sub menu text and links pulled from mySQL using PHP. I've got the php to do this and it work great. However, I now essentially want to just echo the text that the php pulls from the database, in the .js file. How can I do this? Is it an option to bring all of this javascript into the php document where I'm displaying the menus somehow, then run the query in there and effectively add the echo? Thanks guys for any help/suggestions.
×
×
  • 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.