[PHP] Furni SQL Syntax Generator

Status
Not open for further replies.
See if this fixes the drink problem (untested):
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
        <title>SQL Syntax Generator</title> 
        <link rel="stylesheet" href="stylesheet/style.css" /> 
        <script type="text/javascript"> 
            function sel(id){ 
                document.getElementById(id).focus(); 
                document.getElementById(id).select(); 
            } 
            function moreCreditsAndStuffLikeThat(){ 
                m0nsta = 'This product was developed by m0nsta./markeriksson94/iiM4RKx (same person) from RaGEZONE.com\n\nThe original idea was by Drawking from RaGEZONE.com but Stopthatwinkie took his idea and re-did it.\n\nThe threadof Stopthatwinkie is this link: http://forum.ragezone.com/f353/mysql-furniture-code-generator-625374/.\n\nI would also like to thank \'What?\' from RaGEZONE too for re-uploading the program that Stopthatwinkie produced so I didn\'t have to wait 10 minutes to download it.\n\n-----------------------------------------------\n\nIf you are thinking of removing credits to me - die.'; 
                alert(m0nsta); 
            } 
        </script> 
    </head> 
    <div id="tagscanner"> 
        <div style="text-align: center"> 
            <form method="post"> 
                <table width="100%"> 
                    <tbody> 
                        <tr> 
                            <td><label for="tid">TID:</label></td> 
                            <td><input tabindex="1" title="ID of the Catalogue page this item will be in" type="text" name="tid" id="tid" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="cctname">CCT Name:</label></td> 
                            <td><input tabindex="2" type="text" name="cctname" id="cctname" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="catidpage">Catalogue ID Page:</label></td> 
                            <td><input tabindex="3" type="text" name="catidpage" id="catidpage" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="cost">Cost:</label></td> 
                            <td><input tabindex="4" title="Cost of item in credits" type="text" name="cost" id="cost" value="Credits" class="scanclass"> <input tabindex="5" title="Cost of item in Pixels" type="text" name="pixels" id="pixels" value="Pixels" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="top">Top:</label></td> 
                            <td><input tabindex="6" type="text" name="top" id="top" value="0.00" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="status_max">Status Max:</label></td> 
                            <td><input tabindex="7" type="text" name="status_max" id="status_max" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="drink">Drink:</label></td> 
                            <td><select tabindex="8" title="Does this item give drinks? If so, what drink does it give?" name="drink" id="drinks" class="scanclass"> 
                                    <?php 
                                    $drinks = array("0" => "No drink","1" => "Tea","2" => "Juice","3" => "Carrot","4" => "Icecream","5" => "Milk","6" => "Blackcurrant","7" => "Water","8" => "Regular","9" => "Decaff","10" => "Latte","11" => "Mocha","12" => "Macchiato","13" => "Espresso","14" => "Filter","15" => "Iced","16" => "Cappuccino","17" => "Java","18" => "Tap","19" => "Cola","20" => "Camera","21" => "Hamburger","22" => "Lime Soda","23" => "Beetroot","24" => "Bubble Juice","25" => "Love Potion"); 
                                    foreach($drinks as $key=>$value){ 
                                        echo '<option value="'.$key.'">'.$value.'</option>'; 
                                    } 
                                    ?> 
                                </select></td> 
                        </tr> 
                        <tr> 
                            <td><label for="type">Type:</label></td> 
                            <td><select tabindex="9" title="What type of item is this? See options." name="type" id="type" class="scanclass"> 
                                    <?php 
                                    $types = array("0" => "Wall Item","1" => "Solid","2" => "Seat","3" => "Bed","4" => "Rug/Mat"); 
                                    foreach($types as $key=>$value){ 
                                        echo '<option value="'.$key.'">'.$value.'</option>'; 
                                    } 
                                    ?> 
                                </select></td> 
                        </tr> 
                        <tr> 
                            <td><label for="t">Tradable:</label></td> 
                            <td><input tabindex="10" title="Is this item allowed to be traded?" type="checkbox" name="t" id="t" value="1" class="scanclass" checked></td> 
                        </tr> 
                        <tr> 
                            <td><label for="r">Recyclable:</label></td> 
                            <td><input tabindex="11" title="Is this item allowed to be recycled?" type="checkbox" name="r" id="r" value="1" class="scanclass" checked></td> 
                        </tr> 
                        <tr> 
                            <td><label for="rr">Rights Required:</label></td> 
                            <td><input tabindex="12" title="Are room rights required to use this item?" type="checkbox" name="rr" id="rr" value="1" class="scanclass" checked></td> 
                        </tr> 
                        <tr> 
                            <td><label for="d">Door:</label></td> 
                            <td><input tabindex="13" title="Is this item a door?" type="checkbox" name="d" id="d" value="0" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><label for="nt">Next To:</label></td> 
                            <td><input tabindex="14" title="Do you have to be stood next to the item to use it?" type="checkbox" name="nt" id="nt" value="0" class="scanclass"></td> 
                        </tr> 
                        <tr> 
                            <td><input tabindex="15" title="If you are satisfied with the details you have provided, click this button!" type="submit" value="Create SQL Syntax!" name="sql_make" class="scanclass"></td> 
                            <td></td> 
                        </tr> 
                    </tbody> 
                </table> 
            </form> 
        </div> 
        <div name="results" id="results"> 
            <div style="text-align: center"> 
                <?php 
                if(isset($_POST['sql_make'])){ 
                    $tid = strip_tags(stripslashes($_POST['tid'])); 
                    $cctname = strip_tags(stripslashes($_POST['cctname'])); 
                    $catidpage = strip_tags(stripslashes($_POST['catidpage'])); 
                    $cost_credits = strip_tags(stripslashes($_POST['cost'])); 
                    $cost_pixels = strip_tags(stripslashes($_POST['pixels'])); 
                    $top = strip_tags(stripslashes($_POST['top'])); 
                    $statusmax = strip_tags(stripslashes($_POST['status_max'])); 
                    $drink = strip_tags(stripslashes($_POST['drink'])); 
                    $type = strip_tags(stripslashes($_POST['type'])); 
                    $error = ''; 
                    if($_POST['t'] == '1'){ 
                        $t = '1'; 
                    }else{ 
                        $t = '0'; 
                    } 
                    if($_POST['r'] == '1'){ 
                        $r = '1'; 
                    }else{ 
                        $r = '0'; 
                    } 
                    if($_POST['rr'] == '1'){ 
                        $rr = '1'; 
                    }else{ 
                        $rr = '0'; 
                    } 
                    if($_POST['d'] == '1'){ 
                        $d = '1'; 
                    }else{ 
                        $d = '0'; 
                    } 
                    if($_POST['nt'] == '1'){ 
                        $nt = '1'; 
                    }else{ 
                        $nt = '0'; 
                    } 
					if($drink == ''){
						$drink == '0';
					}
                    if(!$tid || !$cctname || !$catidpage || !$cost_credits || !$cost_pixels || !$top || !$statusmax || !$type){ 
                        $error .= '<li>All fields are required.</li>'; 
                    }else{ 
                        if(is_numeric($cost_credits) == false){ 
                            $error .= '<li>The cost of credits must be numeric!</li>'; 
                        }else{ 
                            if(is_numeric($cost_pixels) == false){ 
                                $error .= '<li>The cost of pixels must be numeric!</li>'; 
                            } 
                        } 
                    } 
                    if(!$error){ 
                        $sql_mysql = "INSERT INTO `catalogue_items` (`tid`, `catalogue_cost_credits`, `catalogue_cost_pixels`, `typeid`, `top`, `name_cct`, `status_max`, `rights_required`, `next_to_required`, `drink_ids`, `catalogue_id_page`, `door`, `tradeable`, `recycleable`, `catalogue_id_index`) VALUES ('".$tid."', '".$cost_credits."', '".$cost_pixels."', '".$type."', '".$top."', '".$cctname."', '".$statusmax."', '".$rr."', '".$nt."', '".$drink."', '".$catidpage."', '".$d."', '".$t."', '".$r."', '".$tid."')"; 
                        $sql_php = "<?php mysql_query(\"INSERT INTO `catalogue_items` (`tid`, `catalogue_cost_credits`, `catalogue_cost_pixels`, `typeid`, `top`, `name_cct`, `status_max`, `rights_required`, `next_to_required`, `drink_ids`, `catalogue_id_page`, `door`, `tradeable`, `recycleable`, `catalogue_id_index`) VALUES ('".$tid."', '".$cost_credits."', '".$cost_pixels."', '".$type."', '".$top."', '".$cctname."', '".$statusmax."', '".$rr."', '".$nt."', '".$drink."', '".$catidpage."', '".$d."', '".$t."', '".$r."', '".$tid."')\"); ?>"; 
                        echo '<strong><u>Results</u></strong><br><br> 
                         
                        <strong>MySQL Query Code:</strong><br> 
                        <textarea class="scanclass" name="sql_mysql" id="sql_mysql" style="width:100%;" onclick="sel(\'sql_mysql\');" readonly>'.$sql_mysql.'</textarea> 
                         
                        <br><br> 
                         
                        <strong>PHP Query Code:</strong><br> 
                        <textarea class="scanclass" name="sql_php" id="sql_php" style="width:100%;" onclick="sel(\'sql_php\');" readonly>'.$sql_php.'</textarea>'; 
                    }else{ 
                        echo 'Sorry, we could not generate your SQL Syntax as the following error(s) occurred:<ul>'.$error.'</ul>'; 
                    } 
                } 
                ?> 
            </div> 
        </div> 
    </div> 
    <div> 
        <center> 
            <i>© Mark Eriksson 2010.<br>Coding and programming by Mark Eriksson (m0nsta./markeriksson94/iiM4RKx (same person)).<br>I'm not sure who did the design, but credits to them.<br>Click <strong><a href="mailto:[email protected]">here</a></strong> to send me an e-mail.<br>Click <strong><a href="javascript:moreCreditsAndStuffLikeThat();">here</a></strong> for more information on this product.</i> 
        </center> 
    </div> 
    </body> 
</html>
 
Something similar was released coded in VB.NET or C# by another user, but it's nice to see variations, thanks for the contribution. ;) Also, have you thought about making catalog related php "tools"?

Thx,

~ Moogly
Nope I've not :P
I'm not farmiliar to PHPRetro and all this so I wouldn't know how to code it :-]

Whats TID?
I think it's the ID of the item.
 
Status
Not open for further replies.
Back