You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
I have the following working category display script, but am having a problem getting the foreach to work on the items. - At the moment all related categories are displayed, but not as seperate items (basically the statement is not coded correctly and I am not sure what I need to do to make it display properly). - Can anyone help with this, please?
<?php $ref = $this->globals('khxc.ref'); $ns = $this->globals('khxc.namespace'); $prodidx = $this->globals('ecom.prod_prodidx'); $dispapp = $this->globals('khxc_display.app'); $app = $this->globals('khxc.app'); $eol = $this->globals('khxc.eol'); $proddisp = $this->globals('ecom.prod_proddetail'); $prodnum = $proddisp['prodnum']; include '/var/wetsocks.php'; print '<div class="skin_fenavh"> Product Categories </div>'; print '<div id="skin_fenav1">' . $eol . $eol; print '<table> <tr>'; mysql_pconnect("$s", "$u", "$p") or die(mysql_error()); mysql_select_db("$d") or die(mysql_error()); $result = mysql_query("SELECT DISTINCT id,name,splashdisp,xcat FROM gbu0_cat order by id" ) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { print '<td style="border: 0; padding: 25px 0 0 0; vertical-align: top;">'; if ($row['splashdisp'] = '1') { print '<a class="mobile" href="/gbu0-catshow/' . $row['id'] . '.html" alt="' . $row['name'] . '" />' . $row['name'] . '</a>'; if (!empty($row['xcat'])) { foreach ($row as $num => $listing) { print '<br /><a class="mobile" href="/gbu0-catshow/' . $row['id'] . '.html" alt="' . $row['name'] . '" /> ' . $row['xcat'] . '</a><br />'; } // End of foreach statement. } // End of if statement. } // End of if statement. print '<br /></td></tr><tr>'; } // End of while statement. print '<td> </td></tr></table>'; print '</div>' . $eol . $eol; ?>
Offline
Ah, nothing like being again... - God knows who I've pissed off this time but...
The following works (there does not seem to be any way of saying "we've got , so the field will be whatever" so I've used a to make the display a little more friendly. What anyone else using this script will use is up to them.
You will also need your own (the recipe can be found in some of my earlier posts).
<?php $ref = $this->globals('khxc.ref'); $ns = $this->globals('khxc.namespace'); $prodidx = $this->globals('ecom.prod_prodidx'); $dispapp = $this->globals('khxc_display.app'); $app = $this->globals('khxc.app'); $eol = $this->globals('khxc.eol'); $proddisp = $this->globals('ecom.prod_proddetail'); $prodnum = $proddisp['prodnum']; include '/var/wetsocks.php'; print '<div class="skin_fenavh"> Product Categories </div>'; print '<div id="skin_fenav1">' . $eol . $eol; print '<table> <tr>'; mysql_pconnect("$s", "$u", "$p") or die(mysql_error()); mysql_select_db("$d") or die(mysql_error()); $result = mysql_query("SELECT DISTINCT id,name,splashdisp,xcat FROM gbu0_cat order by id" ) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { print '<td style="border: 0; padding: 25px 0 0 0; vertical-align: top;">'; if ($row['splashdisp'] = '1') { print '<a class="mobile" href="/gbu0-catshow/' . $row['id'] . '.html" alt="' . $row['name'] . '" />' . $row['name'] . '</a><br />'; if (!empty($row['xcat'])) { $listing = (explode(", ",$row['xcat'])); for($i = 0; $i < count($listing); $i++) { print '<div style="line-height: 150%; padding: 20px 0 0 50px;"><a class="mobile_div" href="/gbu0-catshow/' . ($listing[$i]) . '.html" alt="' . $name . '" />' . preg_replace('/_/',' ',($listing[$i])) . '</a><br /></div>'; } // End of for loop. } // End of if statement. } // End of if statement. print '<br /></td></tr><tr>'; } // End of while statement. print '<td> </td></tr></table>'; print '</div>' . $eol . $eol; ?>
Last edited by Design_Wholesale (02-13-2011 09:23:14)
Offline
I may be able to complete this script is someone could tell me how to find something in the database when one value is already known.
For example, if I already have an value for a product listing, how would I go about finding out the for that product using the value that I already have?
Offline
I now have the following, which still does not fix the problem of the wrong name being displayed ( statements, , and all seem to be completely useless for fixing this problem - not sure what else there is - except, possibly, for using several database calls and trying to piece them together afterwards ):
<?php $ref = $this->globals('khxc.ref'); $ns = $this->globals('khxc.namespace'); $prodidx = $this->globals('ecom.prod_prodidx'); $dispapp = $this->globals('khxc_display.app'); $app = $this->globals('khxc.app'); $eol = $this->globals('khxc.eol'); $proddisp = $this->globals('ecom.prod_proddetail'); $prodnum = $proddisp['prodnum']; $catshow = $this->globals('ecom.cat_catshow'); $catname = $this->xhtml_encode($catshow['name']); $catid = $catshow['id']; include '/var/wetsocks.php'; print '<div class="skin_fenavh"> Product Categories </div>'; print '<div id="skin_fenav1">' . $eol . $eol; print '<table> <tr>'; mysql_pconnect("$s", "$u", "$p") or die(mysql_error()); mysql_select_db("$d") or die(mysql_error()); $result = mysql_query("SELECT id,name,splashdisp,xcat FROM gbu0_cat order by id" ) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { print '<td style="border: 0; padding: 25px 0 0 0; vertical-align: top;">'; if ($row['splashdisp'] = '1') { print '<a class="mobile" href="/gbu0-catshow/' . $row['id'] . '.html" alt="' . $row['name'] . '" />' . $row['name'] . '</a><br />'; if (!empty($row['xcat'])) { $listing = (explode(", ",$row['xcat'])); foreach ($listing as $list) { $catname = $row['name']; } // End of foreach statement. for($i = 0; $i < count($listing); $i++) { print '<div style="line-height: 150%; padding: 20px 0 0 50px;"><a class="mobile_div" href="/gbu0-catshow/' . ($listing[$i]) . '.html" alt="' . $catname . '" />' . $catname . '</a><br /></div>'; } // End of for loop. } // End of if statement. } // End of if statement. print '<br /></td></tr><tr>'; } // End of while statement. print '<td> </td></tr></table>'; print '</div>' . $eol . $eol; ?>
The current display (which is currently using the earlier method so I am not left with daft looking listings whilst I am trying to sort this out) can be seen here: http://litez.co.uk/gbu0-display/catmobile.html
Last edited by Design_Wholesale (02-13-2011 11:47:34)
Offline