close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

convert a code block mysql to mysqli

Thread began 3/06/2016 2:12 pm by Christopher West | Last modified 3/08/2016 1:02 pm by Ray Borduin | 167 views | 3 replies |

Christopher WestCommunity Expert

convert a code block mysql to mysqli

Hi, this code was original coded for mysql and I was wondering how easy would it be to convert to mysqli

php:
<?php

mysql_select_db
($database_dinkydb$dinkydb);
$query_CatgFinger "SELECT * FROM productcategories";
$CatgFinger mysql_query($query_CatgFinger$dinkydb) or die(mysql_error());

$menuList = array();
while (
$row =  mysql_fetch_assoc($CatgFinger)) {
    
array_push($menuList,array('CategoryLocation' => $row['CategoryLocation'],'CategoryLink' => $row['CategoryLink'], 'CategoryName' => $row['CategoryName']));
}
?>
<?php
function get_menu_items($menuList = array(), $categroyLocation '') {
    
$obj NULL;
    foreach(
$menuList as $key => $val){
        if(
$val['CategoryLocation'] == $categroyLocation) {
            
$obj .= '<li class="left"><a href="../Category/' $val['CategoryLink'] . '" >' .  $val['CategoryName'] . '</a></li>';    
        }
    }
    
    return 
$obj;
}
?>




html:
<li class="left"><a href="#">Fingerprint Jewellery</a>
<ul class="dropdown">
<?php echo get_menu_items($menuList,'Fingerprint-Jewellery'); ?>
</ul>
</li>
<?php echo get_menu_items($menuList,'Paw-Prints'); ?>
<li class="left"><a href="#">Hands &amp; Feet</a>
<ul class="dropdown">
<?php echo get_menu_items($menuList,'Hands-Feet'); ?>
</ul>
</li>
<?php echo get_menu_items($menuList,'Word-Art'); ?>
<?php echo get_menu_items($menuList,'In-Remembrance'); ?>
<li class="right"><a href="../contact.php">Contact</a></li>
Sign in to reply to this post

Ray BorduinWebAssist

It shouldn't be too difficult. Just add a MySQLi recordset with the same query. Then loop on the result to create the array structure that your code uses. Really it would just be a matter of rewriting those couple of lines of code in your while loop.

Sign in to reply to this post

Christopher WestCommunity Expert

Thanks I will try that. I took this code from old of my older websites and thinking of using it in my current project as finding some issues with how the navigation is used, its more of a logical issue, so hoping this approach will work.

By the way this block of code uses 1 single database table for categories which includes both parent and child menu items. Even though it works. Would you feel that's a bad approach, Could it cause potential issues further up the line?

Sign in to reply to this post

Ray BorduinWebAssist

I don't think it is a bad approach, but you may be able to make the code easier to read by breaking it up... but honestly if it isn't broke don't fix it. I feel like it would be easier to translate the code to mysqli if you weren't also trying to change the structure at the same time.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...