Jump to content

binarywebs

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

binarywebs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Thanks for both replying. Yes The example of product A and B is how I want them to be displayed in my web page. I have one big table with about 35 columns but each product probably only uses 4 of these columns so there is a lot of empty fields in the table. I have got around the problem of having to have lots of if statements to show only relevant columns for each product. I did this by itering through the key and values of each array returned from the database.....as show below; $r = mysqli_query($dbc, "select * from tFullVariables where productId = $pid"); if(mysqli_num_rows($r) > 0) { $mybody = ""; //starts the table and header row $head='<table id="prodoptions" cellspacing="1" border="1"><tr class="head">'; //$c is the counter so that the header is only show once $c = 1; while($myrecord = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $mybody .= '<tr>'; //loops through each key and value of the results array returned by the database foreach($myrecord as $key => $value) { //if the value of the field is empty or 0 then dont show the column or field if($value <> "" && $value <> " " && $value <> "0.00" && $key <> 'id' && $key <> 'productId' ) { if($c ==1) { $head .= '<th>'.$key.'</th>'; } $mybody .= '<td>'.$value.'</td>'; } } $mybody .= '</tr>'; $c=2; } //displays the column headers echo $head.'</tr>'; //displays all of the relevant fields echo $mybody.'</table>'; } If any one can think of a way of doing the above in a relational way using multiple tables instead of one big table that would be good. Thanks
  2. Hello, MYSQL version 5.0.92-community My problem is that I have a database driven website which lists products and their options which have variable field headers for each product e.g Product A may have Capacity and Height which are relevant fields where as Product B has Wattage and Lamp Type which are used to describe the different spec of each product…..as shown below My database currently has one big mysql table for the options for the product which has lots of columns across which I know is not a very productive way of doing it. Ideally I would like to have a more relational way of doing this with maybe a couple of tables like below…. Options Table Option_to_product_id Part_id Option_name Option_value Part Table Part_id Part_number Product_id I’m sure there must be some fancy way of getting the above table views in mysql but I run into problems with getting the column names and also no showing columns that are blank. Does anyone know how to display this in mysql with something like the below? Select columns(un-empty) from t_options to left join tparts tp on tp.id = to.id where product_id = 55 I know the above sql needs to be a lot more complex but hopefully the above will give you an idea. Thanks Daniel
  3. I was looking at mod re-write as a cure to the problem as oppose to a fix so was thinking starting from scratch maybe it could be done from php. I think maybe I was over complicating the situation though. Thanks for putting me back on the right track, I think this is the mod re-write I would need to use to get my desired urls? Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/]+)/([^/]+)/([^/]+).php /index.php?page=$3&parent1=$1&parent2=$2 [NC] Maybe after some further research I could complete this with some if statements for if parent1 or parent2 is not set
  4. No I wasn't intending on doing but now you've pointed that out I suppose that would be the only way, back to the drawing board :'( In your opinion is mod rewrite the only option for achieving Search Engine (SE) friendly urls?
  5. Hello, I am thinking of changing the structure of my CMS for future websites to produce more search engine friendly urls. Currently the urls I get are; www.mydomain.com/index.php?page=wooden-windows What I want to acheive is; www.mydomain.com/windows/wooden-windows/ I know this can be done with mod rewrite but I was thinking this may be possible to do from the get go with php? Here is what I think would be possible; Create links within the cms structure by pulling out the current pages parent e.g. www.mydomain.com/parent1/parent2/actual-page/ then when the page is requested a line of code at the top of the page uses explode to find the last / and retrieves the page as "actual-page". the next bit of code then queries the database and drags out all the info for the record with unique reference "actual-page". Does this sound like it would work properly and does any see any problems that might occur with it? Thanks Dan
  6. No its ok thanks, it appears the guy who started the website is being difficult so I'll just start the bits that don't work again from scatch. Cheers for the help anyway
  7. I think maybe I led this post down the wrong route and the database is just a side issue and the question I should have been asking is; Does PHP encryption work similar to .htpasswd where by there is a text file that contains the paswords or in this case an encryption key or some vital data?
  8. Yes I've just double checked to make sure the data is in the database, some profiles will not show either (vitalia on home page wont but Glyn Jones Will) so I'm wondering if there is something more widespread wrong. The background to this is that I am helping someone out with their website as the other developer let them down with a half finished website. I have just found out that the working website is connecting to a database on the other guys server and not the copy that I have been given which is on their server. Although all the data appears to be in the database could there be something missing from the copy of the database I have or is it likely to be a code file I am missing?
  9. Thanks for the reply. The encryption appears to have been done by the below two sets of code although I don't know much about encryption. This is the code from the action page that searches the database; if($__gSearchSubmit){ header('location: /search/'.Utilities::encrypt('SEARCH',str_replace('&','|',$_SERVER['QUERY_STRING']))); exit; } if($aParameters[1]){ $aSearchParams=explode('|',Utilities::decrypt('SEARCH',$aParameters[1])); foreach($aSearchParams as $sSP){ if(strpos($sSP,'=')!==0){ $aSP=explode('=',$sSP); ${'__p'.$aSP[0]}=$aSP[1]; } } if($__pSearchSubmit){ if($__pUsername){ $sSQL[]="m.sUsername LIKE '%".Database::sanitize($__pUsername)."%'"; } ---------And this is the beginning bit of code from the utilities page that is requested in the above script; # Encryption routine variables static private $_Scramble1 = array(' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./-:_+,#=|','0123456789ABCDEFabcdef'); static private $_Scramble2 = array(fdsgfgdU2q|14y5/y45,4fdgdfgP.dF=Vm DTcS:Zerl#G+KuCyJx-HiQLtRgfhfghfghYnb0X','dFe95fghfghf8C70b2Df61'); static private $_Adj = 1.75; static private $_Mod = 3; ------I've changed some of the encryption letters and numbers just in case its a security leak. Is there something else I need to do from the moving over of the database? Cheers
  10. Hello, I've used PHP and MYSQL before but I'm now trying to learn more advanced uses of it. I have successfully moved a database from one server (mysql = 5.0.67, php = 5.2.4) to another server (mysql = 5.0.67, php = 5.2.8 ) which also has a different domain name. Everything seems to have gone OK apart from the search function does not work on the new server. On the old server clicking search without selecting any criteria returns 8 users whilst on the new server below it returns none; http://www.psm-guitar-shop.co.uk/search Background info - the search has encryption, I have moved all files across to new server, some user profiles on home page will not open, I'm aware work needs doing on tick boxes to get search method perfect. Could it be the change in PHP version that is causing the problem?
×
×
  • 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.