Jump to content

Bar2aYunie

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Bar2aYunie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, after hours of puzzling, I figured out the problem. I do have something else I wanna ask you guys.... (which might save me hours of puzzling, haha) Here's my code: $formaatcat=mysql_real_escape_string($_GET['sizecat']); $eindformaat=$_GET['finalsize']; $thumb_formaat=$_GET['thumb_size']; $bedrukking=$_GET['color']; $papiersoort=$_GET['material']; echo "<table style='width:100%;'>\n\t\t<tr><td align='center' colspan='4'><h1>View Prices</h1></td></tr><tr>"; $finalQuery=mysql_query("SELECT DISTINCT thumb_size, size, totalsize, Info, material, thumb_material, finalsize, color FROM `Folders` WHERE `sizecat`='{$sizecat}' AND `finalsize`='{$finalsize}' AND `color`='{$color}' AND `material`='{$material}' AND `thumb_size`='{$thumb_size}';"); The select query works for the whole line except for the thumb_size... Without that last part, the query returns three rows (and I only need it to return one row). The thumb_size and the totalsize are the only two things in the database that have their own unique data, unique for every entry. So, to be able to get only one row returned from the query, I need one of those at the end of the query (the others wouldn't even be needed actually). But both of them don't work.... Any idea's??
  2. I have a scipt to generate pages with php, but I cannot seem to get the url right. The default page is working and the first step (items) is working just fine. But the next step (color) isn't working. It's either the link that isn't working or the third page itself. Does anybody see what I'm missing or doing wrong? Here's my script: <?php switch($_GET['step']){ case "items": $column=2; $sizecat=mysql_real_escape_string($_GET['size']); echo "<table style='width:100%;'>\n\t\t<tr>"; $itemsQuery=mysql_query("SELECT DISTINCT thumb_sizecat, sizecat, link_size, size, thumb_size, finalsize FROM `Folders` WHERE `sizecat`='{$sizecat}';"); while($item=mysql_fetch_array($itemsQuery)){ $link="?step=color&sizecat=".urlencode($sizecat)."&finalsize=".urlencode($item['finalsize']); if ($column==2) {echo "<tr>";} ?> <td width="25%" align="center"><?php echo "<a href='{$link}'><img src='{$item['thumb_size']}' alt='{$item['thumb_size']}' /><br />{$item['size']}<br />{$item['finalsize']}<br /></a>" ?></td> <?php $column++; if ($column==6) { echo "</tr>"; $column=2; } } echo "</tr><tr><td align='center' colspan='4'><input type=button value='Back' onClick='history.go(-1)'></td></tr></table>\r\n"; break; case "color": $column=2; $finalsize=mysql_real_escape_string($_GET['finalsize']); echo "<table style='width:100%;'>\n\t\t<tr>"; $colorQuery=mysql_query("SELECT DISTINCT thumb_sizecat, sizecat, link_size, size, thumb_size, finalsize, color, link_color, thumb_color FROM `Folders` WHERE `finalsize`='{$finalsize}';"); while($item=mysql_fetch_array($colorQuery)){ $link="?step=material&finalsize=".urlencode($finalsize)."&finalsize=".urlencode($item['finalsize']); if ($column==2) {echo "<tr>";} ?> <td width="25%" align="center"><?php echo "<a href='{$link}'><img src='{$item['thumb_color']}' alt='{$item['thumb_color']}' /><br />{$item['color']}<br /></a>" ?></td> <?php $column++; if ($column==6) { echo "</tr>"; $column=2; } } echo "</tr><tr><td align='center' colspan='4'><input type=button value='Back' onClick='history.go(-1)'></td></tr></table>\r\n"; break; default: $table = "<table style='width:100%;'><tr>\n"; $result = mysql_query("SELECT DISTINCT thumb_sizecat, sizecat, link_size FROM Folders ORDER BY id") or die (mysql_error()); while($row = mysql_fetch_array($result)){ $row['price1'] = round ((($row['price1']+5) *1.85),0); $base_m=5; $row['price11'] = $base_m*(ceil(($row['price1'])/$base_m)); $table.="\t\t<td align='center' style='width:25%;'>" ."<a href='?step=items&size=".urlencode($row['sizecat'])."'><img src='{$row['thumb_sizecat']}' alt='{$row['thumb_sizecat']}' />" ."<br />{$row['sizecat']}</a></td>\n"; $colnum++;if($colnum % 4 == 0) $table.="\t</tr>\n\t<tr>\n"; } $table .= "\t</tr>\n</table>\n"; echo $table; break; } ?> Thx in advance!
  3. Sounds good, can I add the multiplier there as well? If so, how do I do that?
  4. Ah right, I get it. So now for my curiosity... what is OP? Well it is a number, it's a price in fact. Do you perhaps know the answer? I cannot figure out why it doesn't work, or (even worse) how ti fix it... I already have the function... I only need to know how to apply it to all columns....
  5. OP? You mean the database? Well, I am using european decimals, lol... But the database is set to float and I must use us decimals... not that either one of those bothers me, haha. Why you ask? Or did this even answer your question?
  6. (don't know where to edit my post, so I need to post an update) I fixed my column problem, now I only got the calculating problem there. Let me post the table one more time the way it is now: <table width="100%" border="0" rules="groups" table class="table"> <thead> </thead> <tbody> HTML; while ($row = mysql_fetch_assoc($result)){ $row['price'] = round ((($row['price']+5) *1.85),0); $base_m=5; $row['price1'] = $base_m*(ceil(($row['price'])/$base_m)); echo <<<HTML <tr> <td align="center" width="25%"><img src={$row['thumb_name']}><br> {$row['name']}<br> {$row['description']}<br /> {$row['price1']}<br> </td> <td align="left" width="0%"></td> HTML; $row = mysql_fetch_assoc($result); if (!$row){ echo "<td> </td><td> </td>"; } else { echo <<<HTML <td align="center" width="25%"><img src={$row['thumb_name']}><br> {$row['name']}<br> {$row['description']}<br /> {$row['price1']}<br> </td> <td align="left" width="0%"></td> HTML; } $row = mysql_fetch_assoc($result); if (!$row){ echo "<td> </td><td> </td>"; } else { echo <<<HTML <td align="center" width="25%"><img src={$row['thumb_name']}><br> {$row['name']}<br> {$row['descrription']}<br /> {$row['price1']}<br> </td> <td align="left" width="0%"></td> HTML; $row = mysql_fetch_assoc($result); if (!$row){ echo "<td> </td><td> </td>"; } else { echo <<<HTML <td align="center" width="25%"><img src={$row['thumb_name']}><br> {$row['name']}<br> {$row['description']}<br /> {$row['price1']}<br> </td> <td align="left" width="0%"></td> HTML; } } //end if echo "</tr>"; } //end while echo <<<HTML </tbody> <tfoot> <tr> <p><th colspan="4"> $pageNavBar </th> </tr> </tfoot> </table> As you can see, I added a function to get the price from the database and then add the administration fee and then add the multiplier. However, this function only seems to work for the first column. The others won't display any price. Does anybody know how to fix this? Am I doing something wrong? I also tried adding the same line in again and renaming the function (to price2 with same calculation), but that also dosen't work. Do I need to apply the function for all columns for it work or something? I'd be grateful if somebody can help me out, I don't see it! Thx!
  7. Try using two divs: <div id="backgroundone"> <div id="backgroundtwo"> </div> </div> You can then style everything with css. Try this.
  8. I haven't tested this, but try using divs... Here's an example: <div id="backgroundone"> <div id="backgroundtwo"> </div> </div> You can then style everything with css. Try this.
  9. What do you want to display? The 100% height of the table or is it the background you wish to view for 100%?
  10. I'd go for css, but can't you just also create an image with whatever program you have (eg photoshop) and add the blank space in the image itself? Might be too simple, but if it's only blank space you need.....
  11. Do you mean that the text still is read from top to bottom, like this: t e x t Or do you mean that you'd have to turn your head to read it?
  12. I think I've got something... $row['prijs1'] = round ((($row['prijs1']+5) *1.85),0); $base_m=5; $row['prijs11'] = $base_m*(ceil(($row['prijs1'])/$base_m)); That gives me 540 as a result. So looks good. I do have another problem.... I left a part of the code out, cos I thought it might be too much at once. But that part gives me no result at all at this point. Here's the total code: <?php include ("../Connection.txt"); ?> <?php $id = $_GET['id']; $maxcol = 4; $result = mysql_query("SELECT * FROM Folders order by id desc") or die (mysql_error()); $count = mysql_num_rows($result); $rows = ceil($count/$maxcol); echo "<table>"; $limit = 20; $table = 'Folders'; //get requested page $page = empty($_GET['page']) ? 1 : (int) $_GET['page']; //calculate offset $offset = ($page - 1) * $limit; //construct query $query = "Select SQL_CALC_FOUND_ROWS * from $table order by formaat desc LIMIT $limit OFFSET $offset"; //execute query $result = mysql_query($query) or die (mysql_error()); $cResult = mysql_query("Select found_rows()") or die(mysql_error()); list($count) = mysql_fetch_array($cResult, MYSQL_NUM); $pageNavBar = getPages($limit, $count, $page); //start the output echo <<<HTML <style type="text/css"> /*style links */ .pageNav a {text-decoration:none; cursor:crosshair; color: #131d31;} .pageNav a:visited {text-decoration:none; color: #131d31;} /*make the page numbering smaller generally */ .pageNav{ font-size:smaller;} .page{ border: thin dotted #060409; background-color:#fdffeb;} .navi{ padding: 5px; margin: 2px; width: 2em;} .prev{} .last{ background-color:;} .first{ background-color:;} .next{} .active {backround-color:grey; color:red;} .select select {} .table {font-family: verdana; font-size: 12px;} </style> <table width="100%" border="0" rules="groups" table class="table"> <thead> </thead> <tbody> HTML; while ($row = mysql_fetch_assoc($result)){ $row['prijs1'] = round ((($row['prijs1']+5) *1.85),0); $base_m=5; $row['prijs11'] = $base_m*(ceil(($row['prijs1'])/$base_m)); echo <<<HTML <tr> <td align="center" width="50%"><a href="/Producten/Flyers/Flyers_Bedrukking_A7L.html"><img src={$row['thumb_formaat']}><br> {$row['formaat']}<br> {$row['eindformaat']}<br /> {$row['prijs11']}</a><br> </td> <td align="left" width="0%"></td> HTML; $row = mysql_fetch_assoc($result); if (!$row){ echo "<td> </td><td> </td>"; } else { echo <<<HTML <td align="center" width="50%"><a href="/Producten/Flyers/Flyers_Bedrukking_A7L.html"><img src={$row['thumb_formaat']}><br> {$row['formaat']}<br> {$row['eindformaat']}<br /> {$row['prijs1']}</a><br> </td> <td align="left" width="0%"></td> HTML; } //end if echo "</tr>"; } //end while echo <<<HTML </tbody> <tfoot> <tr> <p><th colspan="4"> $pageNavBar </th> </tr> </tfoot> </table> HTML; function getPages($limit, $count, $page){ //put the url into a variable $s = "http://" . $_SERVER['HTTP_HOST'] .'/'. ltrim($_SERVER["SCRIPT_NAME"] ,'/'); //calculate the number of pages needed $nPages = ceil($count/$limit); //do the first/last prev/next buttons $first = <<<HTML <span class="first navi"> <a href="$s?page=1"><<<</a> </span> HTML; $last = <<<HTML <span class="last navi"> <a href="$s?page=$nPages">>>></a> </span> HTML; if ($page > 1) { $p = $page - 1; $prev = <<<HTML <span class="next navi"> <a href="$s?page=$p"><</a> </span> HTML; } else { $prev = ' '; $first = ' '; } if ($page < $nPages) { $p = $page + 1; $next = <<<HTML <span class="next navi"> <a href="$s?page=$p">></a> </span> HTML; } else { $next = ' '; $last = ' '; } //now construct the pages //if more than 10 then use a select if ($nPages > 10){ $output = <<<HTMLJS <span class="navi select"> <select name="page" onchange="window.location='{$s}?page=' + this.options[this.selectedIndex].value;"> HTMLJS; for ($p=1; $p <=$nPages; $p++){ $output .= "<option value=\"$p\">$p</option>"; } $output .= '</select></span>'; } else { $output = ''; for ($p=1; $p<=$nPages; $p++){ $active = ($p == $page) ? 'active' : ''; $output .= "<span class=\"navi page {$active}\"><a href=\"$s?page=$p\">$p</a></span>"; } } return '<div class="pageNav">' . $first . $prev. $output . $next . $last . '</div>'; } ?> As you can see I've got another column with the same set of data... I actually need four columns with in all four columns the same data. It has four columns at this point, but two of them are empty. If I fill the second and fourth column with the same code, it only copies the code from the previous column, thus column one and three. In column three, there's no price at all.... Any idea why? Maybe it's easier to fix if I point out my plan in the end... I need four columns like this: image1 - image2 - image3 - image4 infotxt1 - infotxt2 - infotxt3 - infotxt4 I can't seem to get that fixed either. Can you help out with these two problems?
  13. Well I'm not exactly sure what you meant... But I found out that I can use . instead of , to calculate it. So I changed the value of 285,25 in the table to 285.25 (since I noticed that the ,25 a the end was deleted once I set the row to float). And (while I was waiting for your reply) I did some more searching and I found this. That's how I got it to have 2 decimals! So now I changed that last part of code to: $row['price1'] = round ((($row['price1']+5) *1.85),2); And, as price1 has a value of 285,25.... I now get a value of 536.96! The only thing is, some of the prices need to be rouned per 5 dollars. Meaning 536.96 should be rounded to 540. Any idea how I can round those?
  14. Okay, so I've changed it to float... But how do I create the calculation now?
  15. well I have a table containing one of the products, and in the table there's the name, description, size and so on and then the price so it states: amount1 = 500 price1 = 285,25 amount2 = 1000 price2 = 423,67 (10 amounts and 10 prices per product) and so on. Previously, I was calculating all of the prices manually before inserting the prices into the tables. But now I'd like to have the standard prices for the prouducts and then insert the multiplyer and the administration cost into the script. So that when those change later on, I don't have to change thousands of prices manually, but just those two values in the script. Was that the info you needed?
×
×
  • 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.