Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Can I know from the professionals here, what is the best method to write this kind of logic? And also I would like to know is there other way to write this in a best way. Method 01: if ($emission <= 100 ) { $cssClass = "emission_a"; } elseif ($emission <= 120 ) { $cssClass = "emission_b"; } elseif ($emission <= 150 ) { $cssClass = "emission_c"; } elseif ($emission <= 165 ) { $cssClass = "emission_d"; } elseif ($emission <= 185 ) { $cssClass = "emission_e"; } else { $cssClass = "emission_g"; } Method 02: $mapping = array( 100 => 'emission_a', 120 => 'emission_b', 150 => 'emission_c', 165 => 'emission_d', 185 => 'emission_e', 225 => 'emission_f' ); $cssClass = 'emission_g'; // default class if $emission is > 225 foreach ($mapping as $limit => $class) { if ($emission <= $limit) { $cssClass = $class; break; } } Thank you.
  2. hi, guys i have a problem in outputting the id in php. what i'm trying to do is create a article and when the user clicks the edit button the text area shows up for editing while the original article hides. i'm using both jquery and php to do it. the problem is that when the user clicks the edit button the hidden text area doesn't showup when i looked in to the browser source i found that the id is not outputting in the hidden textarea. so, please guide me on how to print the id in the hidden area. here is the code for jquery : $(".hidden_text_edit").click(function(){ var id=$(this).attr("id"); $(".hidden_edit_4_session").find("id").show(); var hide_status=$(".statusboxes").attr('type'); var title=$(".title_s_2copy").attr('type'); var data=$(".data_s_2copy").attr('type'); $(hide_status).hide(); //tinyMCE.get('.hidden_edit_4_session').setContent(data); $(".title_s_edit").val(title); }); $(".close_edit").click(function(){ $(".hidden_edit_4_session").hide(); var hide_status=$(".statusboxes").attr('div', 'type'); $(hide_status).show(); }); code for article and hidden text area logic: <?php if(isset($_SESSION['app'])){ $statusui="<div class='jumbotron'><input type='text' class='form-control title_s' name='status_title' placeholder='Title ' ><br>" . "<textarea id='wall_id_1' class='update_session' placeholder='whats up ".$session_uname."'>" . "</textarea>" . "<button style='float:right;' type='a' class='btn btn-warning btn btn-large btn-lg post-s'>Post</button></div>"; $statusui_edit="<div id=".$updateid." class='hidden_edit_4_session".$updateid." jumbotron'><a href='#' class='pull-right close_edit' title='Close without editing'>Close X</a><input type='text' class='form-control title_s_edit' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' ><div> </div>" . "<textarea id='wall_edit_1' value='".html_entity_decode($data)."' class='session_edit' placeholder='whats up ".$session_uname."'>" . "" .html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>"; } elseif ($is_friend==TRUE&&$session_uname!=$f_uname) { $statusui="<input type='text' class='form-control title_f' name='status_title' placeholder='Title'><br>" . "<textarea id='wall_id_1' type='c' value='".html_entity_decode($data)." class='status_4_expresspad_friend' style='' placeholder='hi ".$session_uname." want to say something to ".$f_uname.". '>" . "</textarea><br>" . "<button style='float:right;' class='btn btn-warning btn-large btn-lg post-f'>Post</button><br><br><br><div> </div>"; $statusui_edit="<div class='hidden_edit_4_friend jumbotron'><a title='Close without editing' href='#' class='pull-right close_edit_f'>Close X</a><input type='text' class='form-control title_f_edit' name='status_title' value='".html_entity_decode($title)."' placeholder='Title'><br>" . "<textarea id='wall_edit_2' value='".html_entity_decode($data)."' class='update_4_expresspad'placeholder='hi ".$session_uname." want to say something to ".$f_uname.". '>" . "</textarea><br>" . "<button style='float:right;' type='c' class='btn btn-warning btn-large btn-lg post-f-edit'>Update</button>"; } ?> here is the code where the status list is outputting in a loop with the hidden text area's logic: <?php $status2view=$project->statusView($session_uname, $f_uname); //gives output on var dump #row vars to extract user's update data. foreach($status2view as $row){ $id=$row['update_id']; $status_replies_=$project->reply2StatusView($id); foreach ($status_replies_ as $row) { $status_reply_id=$row['update_id']; $reply_author=$row['author']; $reply_d=htmlentities($row['update_body']); $reply_data= stripslashes($reply_d); $reply_t= htmlentities($row['title']); $reply_title= stripslashes($reply_t); $account_name=$row['account_name']; $reply_date=$row['time']; $reply_delete_button=""; if ($reply_author==$session_uname || $account_name==$session_uname) { $reply_delete_button="<li><span id='$status_reply_id' class='delete_reply_btn glyphicon glyphicon-remove'><a href='#' title='Delete this comment'>Remove X</a></span></li>"; } $status_replies="<div id='".$status_reply_id."' class='replyboxes'><b>Reply by<a href='search_results.php?u=".$reply_author."'>".$reply_author."</a>".$reply_date ."<legend>" . "<b class='caret'><button type='button' class='btn btn-danger dropdown-toggle pull-right' data-toggle='dropdown' aria-expanded='true' ><span class='glyphicon glyphicon-edit'></span> <ul class='dropdown-menu'>".$reply_delete_button." " . "<li><a href='#' class='hidden_text_area glyphicon glyphicon-pencil' title='Edit this comment' >Edit</a></li>" . "<li><a href='report.php?u='".$reply_author."'>Report</a><li></ul>" . "</button></b></legend><br>". html_entity_decode($reply_data).""; } } foreach ($status2view as $row1) { //got values here. $updateid=$row1['update_id']; $account_name=$row1['account_name']; $os_id=$row1['os_id']; $author=$row1['author']; $post_date=$row1['time']; $title= $row1['title']; $data= $row1['update_body']; $statusdeletebutton=''; if ($author==$session_uname || $account_name==$session_uname) { $statusdeletebutton='<li>' . '<a href="#" id="'.$updateid.'" class="delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_reply_btn" title="Delete this status and its replies">Remove</a></li>'; } $status_list= '<div id="'.$updateid.'" type="'.$updateid.'" class="statusboxes jumbotron">' . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left"><div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' . '<li><a href="#" id="'.$updateid.'" type="'.$updateid.'" class="edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'.$statusdeletebutton.'</ul></div></span><br><hr><span class="pull-left data_s_2copy" id="'.$updateid.'" value="'.html_entity_decode($data).'" style="font-size:9px; margin-bottom:0px; margin-top:0px; text-align:left; color:black;">' . html_entity_decode($data).'</span><br><br><hr><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br>'.$status_replies.'<br>'.$statusui_edit; if ($is_friend==TRUE||$session_uname==$f_uname) { $status_list.= '<textarea id="'.$updateid.'" class="status_update input-custom2" placeholder="comment\'s"></textarea>' . '<button id="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm">Reply</button></div>'; } echo $status_list; }
  3. I have some code where a user can enter a file name/number separated by a comma. At the moment, I am checking for duplicate entries against a MySql database, which works well. However, I also need a way to check if a user has input the same entry so upon submission, example, a1b2c3,a1b2c3. I can catch this and trigger or echo an alert and halt the execution of the script. If there are no dupe entries, proceed to check db. I have been struggling with this and need to find a way to check before the check db code.I turn to the exerts for some guidance/assistance with this. I would be grateful for any help with this so I can move forward and learn something new in the process. Many thanks. <?php if (isset($_POST['file_add'])) { if (!empty($_POST['file_add'])) { $filedata = split(',', $_POST['file_add'][0]); $fileadd = array(); $fileduplicates = array(); foreach ($filedata as $val3) { if ($val3 != "") { $sql = "SELECT custref FROM files WHERE custref='$val3' AND customer = '" . $_SESSION['kt_idcode_usr'] . "'"; $qry = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($qry)) { $fileduplicates[] = $val3; } else { $fileadd[] = $val3; $flag = 1; } } else { $fileerror = '<span style="font-weight:bold;font-size:12px;color: #ff0000;">' . 'FILE ERROR! ' . '</span>' . '<span style="font-weight:normal;color: #000;background-color:#ffa;">' . 'You must enter a file for intake' . '</span>'; echo "<script language=\"JavaScript\">\n"; echo 'alert("FILE ERROR:\nYou must enter a file for intake.");'; echo " </script>"; echo $fileerror; } } if (count($fileadd)) { echo 'You wish to add file(s): ' . ' <div style="word-wrap:break-word;white-space: pre-wrap;overflow:auto !important;height: 100px; width: 250px; border: 1px solid #666; background-color: #fff; padding: 4px;">' . '<span style="font-weight:bold;color: #000;">' . join(', ', $fileadd) . '</span>' . '</div> ' . ' <p /> '; //if(count($duplicates) == 0) // add to session only if we have no duplicates $_SESSION['file_add'] = $fileadd; /// change here, do not store $_POST since it can contain duplicates } if (count($fileduplicates)) { $filedupeerror = "ERROR:" . " " . "File" . " " . '(' . join(', ', $fileduplicates) . ')' . " " . "This file is already in the database"; echo "<script language=\"JavaScript\">\n"; echo 'alert("FILE ERROR:\nThis file is already in the database");'; echo " </script>"; echo $filedupeerror; } } } ?>
  4. how can I make this regex allow punction marks "/^([a-zA-Z\s ]){4,30}$/" At the moment it doesn't.
  5. Hello, I have an Internet Radio station and I use Shoutcast. I have a function that allows me to grab the song and artist information such as Del Amitri - Roll To Me and show it on my website, and automatically changing when the songs change. I show the now playing, and last three songs. I'm wondering How I can get it to also pull in album artwork from Last.FM or Amazon such as this website: BIG 106.5 - Dayton's 70s & 80s Hits (move over the black bar and drop down). You will be able to see something such that I would want to accomplish. Not sure if this merely Javascript, or if there's also PHP.. but then again, I'd think Javascript for it to automatically change when a new song plays. Here is the file I currently have setup...which pulls the information from my shoutcast stream. I would love to incorporate album art from Amazon and/or an internal database that I have setup.. Here is what the file currently looks like. I also have stuff commented out for which I am not using ATTM. It pulls the song like artist - title <!--<html> <head>--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script> <script src="http://wlqtdb.com/wayne/pollstation.js" type="text/javascript"></script> <!--</head> <body>--> Now Playing on WLQT-DB: <!--<div id="currentsong"> </div>--> <span id="currentsong"></span> Recently Played: <!--<table> <tr><th>Recently Played Songs</th></tr> <tr><td><img id='prevsong1' alt=""><span id="prevsong1"></span></td></tr> <tr><td><span id="prevsong2"></span></td></tr> <tr><td><span id="prevsong3"></span></td></tr>--> <span id="prevsong1"></span> <span id="prevsong2"></span> <span id="prevsong3"></span> <!--<tr><td><span id="prevsong4"></span></td></tr> <tr><td><span id="prevsong5"></span></td></tr> <tr><td><span id="prevsong6"></span></td></tr> <tr><td><span id="prevsong7"></span></td></tr> <tr><td><span id="prevsong8"></span></td></tr> <tr><td><span id="prevsong9"></span></td></tr> <tr><td><span id="prevsong10"></span></td></tr>--> <!-- </table> Testing: <? echo "$currentsong"; ?> </body> </html>--> Any help would be greatly appreciated. As you can see with this result, I do the Current playing song, then it does the last 3 songs. Thanks
  6. hi guys im trying to hide a specific class selector in jquery. where the id and the type attributes are generated dynamically. but dont know how to select and hide it so, as to do a ajax call. can anyone help. here is the code for the jquery: $(".hidden_text_area").click(function(){ $(".hidden_edit_4_session").show(); var hide_status=$(".statusboxes").attr('type'); $(hide_status).find(".statusboxes").hide(); }); and here is the code where the type attribute is which i want to select and hide if the user clicks edit button. $status_list='<fieldset><div class="jumbotron"><div id="'.$updateid.'" type="'.$updateid.'" class="statusboxes">' . '<h3 style="text-align:left; color:black;" class="pull-left">'.$title.'</h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' . '<li><a href="#" class="hidden_text_area glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'.$statusdeletebutton.'</ul></div></span><br><hr><span class="pull-left"style="font-size:14px; text-align:left; color:black;"><legend>' . $data.'</legend></span><br><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br>'.$status_replies . '</div></div>'.$statusui_edit ;
  7. As usual, I'm in over my head. I'm generating a key to be used in an confirmation email. For testing, I have: <?php $email = 'email@email.com'; echo $key = sha1($email.'my_super_duper_secret_sauce_here'.microtime()); $url = 'https://www.mysite.com/?'.$key; echo $url; $key2 = var_dump(parse_url($url, PHP_URL_QUERY )); echo $key2; if($key == $key2) { echo "="; } else { echo "!="; } ?> which produces: 3d6d7dddc7cc9b3571078e8032f69c5ee4ef1256 https://www.mysite.com/?3d6d7dddc7cc9b3571078e8032f69c5ee4ef1256 string(40) "3d6d7dddc7cc9b3571078e8032f69c5ee4ef1256" != How do I get rid of string(40) and the beginning and tailing quotation marks so that all I have left for $key2 will equal the $key? I've tried substr(), trim(), and rtrim(). And while one of those (or some combination) may be what I need, I don't know how to use them to get rid of the unwanted chars from using var_dump(parse_url($url, PHP_URL_QUERY )) Any help on this is appreciated. Thanks.
  8. I have to complete a multidimensional array, I have written PHP code but I keep getting numbers ontop of the arrays? Moreover; could you give me feedback on the multidimensional array is it anygood? <?php $customers = array( $customers =['Name' => 'Bob','id' => '587','Date' => '17/10/1015',], $customers =['Name' => 'Stu','id' => '100','Date' => '02/04/2010', ], $customers =['Name' => 'Kate','id' => '12','Date' => '09/12/2013',], ); $keys = array_keys($customers); $keys = array_keys($customers); for($i = 0; $i < count($customers); $i++) { echo $keys[$i] . "<br>"; foreach($customers[$keys[$i]] as $key => $value) { echo $key . " : " . $value . "<br>";} echo "<br>";} ?> //Ouput: 0Name : Bobid : 587Date : 17/10/1015 1Name : Stuid : 100Date : 02/04/2010 2Name : Kateid : 12Date : 09/12/2013
  9. I am using this php function to display categories and sub-categories in a list. function displayMenuMobile(&$cats, $parent, $level=0) { switch ($level) { case 0: $class = "menu-phone"; $menuId = "nav"; break; case 1: $class = "sub-menu"; $menuId = ""; break; } if ($parent==0) { foreach ($cats[$parent] as $id=>$nm) { displayMenuMobile($cats, $id); } } else { echo "<ul class='$class' id='$menuId'>\n"; $classParent = ''; if ($level == 0) { $classParent = "class='parent'"; } foreach ($cats[$parent] as $id=>$nm) { echo "<li $classParent><a href='#'><span>$nm</span></a>\n"; if (isset($cats[$id])) { displayMenuMobile($cats, $id, $level+1); //increment level } } echo "</li></ul>\n"; } } Its displaying the list but it is not rendering HTML properly. This is rendering HTML: <ul class='menu-phone' id='nav'> <li class='parent'><a href='#'><span>Hot Deals</span></a> <li class='parent'><a href='#'><span>Pantry</span></a> <ul class='sub-menu' id=''> <li ><a href='#'><span>Biscuits</span></a> <li ><a href='#'><span>Canned Foods</span></a> <li ><a href='#'><span>Canned Vegetables</span></a> <li ><a href='#'><span>Chips, Snacks & Nuts</span></a> </ul> <li class='parent'><a href='#'><span>Drinks</span></a> <ul class='sub-menu' id=''> <li ><a href='#'><span>Coffee</span></a> <li ><a href='#'><span>Flavoured Milk Drinks</span></a> </ul> <li class='parent'><a href='#'><span>Confectionery</span></a> <ul class='sub-menu' id=''> <li ><a href='#'><span>Chocolate</span></a> <li ><a href='#'><span>Mints &Bathroom & Toilet Gums </span></a></li> </ul> <li class='parent'><a href='#'><span>Household</span></a> <ul class='sub-menu' id=''> <li ><a href='#'><span>Air Fresheners</span></a> <li ><a href='#'><span>Bathroom & Toilet</span></a> <li ><a href='#'><span>Cleaning</span></a> <li ><a href='#'><span>Electrical</span></a> <li ><a href='#'><span>Homeware</span></a> <li ><a href='#'><span>Laundry</span></a></li> </ul> <li class='parent'><a href='#'><span>Cosmetics</span></a> <ul class='sub-menu' id=''> <li ><a href='#'><span>Eye Makeup</span></a> <li ><a href='#'><span>Lip Gloss & Moisturisers</span></a> <li ><a href='#'><span>Nail Polish</span></a></li> </ul> </li> </ul> Problem is its not rendering closing </li> tag in the parent and nested list. Can anybody tell me whats wrong with this? Hope somebody may help me out. Thank you.
  10. Please excuse my messy code I am still very much learning how to use PHP. I have a php file that creates an xml file which then gets sent to my client using phpmailer. What is happening is when clients fill in my form/application it is allowing some ampersands and that is creating an issue when he is trying to import the xml into excel. What I was trying to do is us the htmlspecialchars function to fix this issue. My code is below which i have not synced up to the server yet as I want to make sure it will work. I really only need to make sure that any POST data in regards to ZONES is cleaning up any special characters. <?php foreach ($_POST as $key => $value) { $_POST[$key] = htmlspecialchars($value); } $myFile = "{$_POST['Last_Name']}-{$_POST['Request_Number']}.xml"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<?xml version='1.0' encoding='windows-1250'?> <project> <RequestNumber>{$_POST['Request_Number']}</RequestNumber> <company>{$_POST['Company']}</company> <firstname>{$_POST['First_Name']}</firstname> <lastname>{$_POST['Last_Name']}</lastname> <phone>{$_POST['Phone']}</phone> <fax>{$_POST['Fax']}</fax> <email>{$_POST['Email']}</email> <address>{$_POST['Address']}</address> <city>{$_POST['City']}</city> <state>{$_POST['State']}</state> <zipcode>{$_POST['Zipcode']}</zipcode> <ProjectName>{$_POST['Project_Name']}</ProjectName> <ProjectZipcode>{$_POST['Project_Zipcode']}</ProjectZipcode> <Ease>{$_POST['Ease_of_Installation']}</Ease> <Performance>{$_POST['Performance']}</Performance> <startdate>{$_POST['Start_Date']}</startdate> <installerlevel>{$_POST['Installer_Level']}</installerlevel> <Heatsource>{$_POST['Heatsource']}</Heatsource> <overallstructureinsulation>{$_POST['Overall_structure_insulation']}</overallstructureinsulation> <comments>{$_POST['Comments']}</comments> <ZoneName> <ZoneName1>{$_POST['Zone_Name']}</ZoneName1> <ZoneName2>{$_POST['Zone_Name2']}</ZoneName2> <ZoneName3>{$_POST['Zone_Name3']}</ZoneName3> <ZoneName4>{$_POST['Zone_Name4']}</ZoneName4> <ZoneName5>{$_POST['Zone_Name5']}</ZoneName5> <ZoneName6>{$_POST['Zone_Name6']}</ZoneName6> <ZoneName7>{$_POST['Zone_Name7']}</ZoneName7> <ZoneName8>{$_POST['Zone_Name8']}</ZoneName8> <ZoneName9>{$_POST['Zone_Name9']}</ZoneName9> <ZoneName10>{$_POST['Zone_Name10']}</ZoneName10> </ZoneName> <DesignTemperature> <DesignTemp1>{$_POST['Design_Temperature']}</DesignTemp1> <DesignTemp2>{$_POST['Design_Temperature2']}</DesignTemp2> <DesignTemp3>{$_POST['Design_Temperature3']}</DesignTemp3> <DesignTemp4>{$_POST['Design_Temperature4']}</DesignTemp4> <DesignTemp5>{$_POST['Design_Temperature5']}</DesignTemp5> <DesignTemp6>{$_POST['Design_Temperature6']}</DesignTemp6> <DesignTemp7>{$_POST['Design_Temperature7']}</DesignTemp7> <DesignTemp8>{$_POST['Design_Temperature8']}</DesignTemp8> <DesignTemp9>{$_POST['Design_Temperature9']}</DesignTemp9> <DesignTemp10>{$_POST['Design_Temperature10']}</DesignTemp10> </DesignTemperature> <SnowMeltingClass> <SnowMelting1>{$_POST['Snow_Melting']}</SnowMelting1> <SnowMelting2>{$_POST['Snow_Melting2']}</SnowMelting2> <SnowMelting3>{$_POST['Snow_Melting3']}</SnowMelting3> <SnowMelting4>{$_POST['Snow_Melting4']}</SnowMelting4> <SnowMelting5>{$_POST['Snow_Melting5']}</SnowMelting5> <SnowMelting6>{$_POST['Snow_Melting6']}</SnowMelting6> <SnowMelting7>{$_POST['Snow_Melting7']}</SnowMelting7> <SnowMelting8>{$_POST['Snow_Melting8']}</SnowMelting8> <SnowMelting9>{$_POST['Snow_Melting9']}</SnowMelting9> <SnowMelting10>{$_POST['Snow_Melting10']}</SnowMelting10> </SnowMeltingClass> <TypeOfTubing> <Tubing1>{$_POST['Tubing']}</Tubing1> <Tubing2>{$_POST['Tubing2']}</Tubing2> <Tubing3>{$_POST['Tubing3']}</Tubing3> <Tubing4>{$_POST['Tubing4']}</Tubing4> <Tubing5>{$_POST['Tubing5']}</Tubing5> <Tubing6>{$_POST['Tubing6']}</Tubing6> <Tubing7>{$_POST['Tubing7']}</Tubing7> <Tubing8>{$_POST['Tubing8']}</Tubing8> <Tubing9>{$_POST['Tubing9']}</Tubing9> <Tubing10>{$_POST['Tubing10']}</Tubing10> </TypeOfTubing> <TypeOfInstallation> <Type_of_Installation1>{$_POST['Type_of_Installation']}</Type_of_Installation1> <Type_of_Installation2>{$_POST['Type_of_Installation2']}</Type_of_Installation2> <Type_of_Installation3>{$_POST['Type_of_Installation3']}</Type_of_Installation3> <Type_of_Installation4>{$_POST['Type_of_Installation4']}</Type_of_Installation4> <Type_of_Installation5>{$_POST['Type_of_Installation5']}</Type_of_Installation5> <Type_of_Installation6>{$_POST['Type_of_Installation6']}</Type_of_Installation6> <Type_of_Installation7>{$_POST['Type_of_Installation7']}</Type_of_Installation7> <Type_of_Installation8>{$_POST['Type_of_Installation8']}</Type_of_Installation8> <Type_of_Installation9>{$_POST['Type_of_Installation9']}</Type_of_Installation9> <Type_of_Installation10>{$_POST['Type_of_Installation10']}</Type_of_Installation10> </TypeOfInstallation> <SlabThickness> <SlabThickness1>{$_POST['Slab_Thickness']}</SlabThickness1> <SlabThickness2>{$_POST['Slab_Thickness2']}</SlabThickness2> <SlabThickness3>{$_POST['Slab_Thickness3']}</SlabThickness3> <SlabThickness4>{$_POST['Slab_Thickness4']}</SlabThickness4> <SlabThickness5>{$_POST['Slab_Thickness5']}</SlabThickness5> <SlabThickness6>{$_POST['Slab_Thickness6']}</SlabThickness6> <SlabThickness7>{$_POST['Slab_Thickness7']}</SlabThickness7> <SlabThickness8>{$_POST['Slab_Thickness8']}</SlabThickness8> <SlabThickness9>{$_POST['Slab_Thickness9']}</SlabThickness9> <SlabThickness10>{$_POST['Slab_Thickness10']}</SlabThickness10> </SlabThickness> <ThinSlab> <thinslab1>{$_POST['Thin_Slab']}</thinslab1> <thinslab2>{$_POST['Thin_Slab2']}</thinslab2> <thinslab3>{$_POST['Thin_Slab3']}</thinslab3> <thinslab4>{$_POST['Thin_Slab4']}</thinslab4> <thinslab5>{$_POST['Thin_Slab5']}</thinslab5> <thinslab6>{$_POST['Thin_Slab6']}</thinslab6> <thinslab7>{$_POST['Thin_Slab7']}</thinslab7> <thinslab8>{$_POST['Thin_Slab8']}</thinslab8> <thinslab9>{$_POST['Thin_Slab9']}</thinslab9> <thinslab10>{$_POST['Thin_Slab10']}</thinslab10> </ThinSlab> <OverSubfloor> <OverSubfloor1>{$_POST['Over_Subfloor']}</OverSubfloor1> <OverSubfloor2>{$_POST['Over_Subfloor2']}</OverSubfloor2> <OverSubfloor3>{$_POST['Over_Subfloor3']}</OverSubfloor3> <OverSubfloor4>{$_POST['Over_Subfloor4']}</OverSubfloor4> <OverSubfloor5>{$_POST['Over_Subfloor5']}</OverSubfloor5> <OverSubfloor6>{$_POST['Over_Subfloor6']}</OverSubfloor6> <OverSubfloor7>{$_POST['Over_Subfloor7']}</OverSubfloor7> <OverSubfloor8>{$_POST['Over_Subfloor8']}</OverSubfloor8> <OverSubfloor9>{$_POST['Over_Subfloor9']}</OverSubfloor9> <OverSubfloor10>{$_POST['Over_Subfloor10']}</OverSubfloor10> </OverSubfloor> <JoistSpacing> <JoistSpacing1>{$_POST['Joist_Spacing']}</JoistSpacing1> <JoistSpacing2>{$_POST['Joist_Spacing2']}</JoistSpacing2> <JoistSpacing3>{$_POST['Joist_Spacing3']}</JoistSpacing3> <JoistSpacing4>{$_POST['Joist_Spacing4']}</JoistSpacing4> <JoistSpacing5>{$_POST['Joist_Spacing5']}</JoistSpacing5> <JoistSpacing6>{$_POST['Joist_Spacing6']}</JoistSpacing6> <JoistSpacing7>{$_POST['Joist_Spacing7']}</JoistSpacing7> <JoistSpacing8>{$_POST['Joist_Spacing8']}</JoistSpacing8> <JoistSpacing9>{$_POST['Joist_Spacing9']}</JoistSpacing9> <JoistSpacing10>{$_POST['Joist_Spacing10']}</JoistSpacing10> </JoistSpacing> <Subfloor> <Subfloor1>{$_POST['Subfloor']}</Subfloor1> <Subfloor2>{$_POST['Subfloor2']}</Subfloor2> <Subfloor3>{$_POST['Subfloor3']}</Subfloor3> <Subfloor4>{$_POST['Subfloor4']}</Subfloor4> <Subfloor5>{$_POST['Subfloor5']}</Subfloor5> <Subfloor6>{$_POST['Subfloor6']}</Subfloor6> <Subfloor7>{$_POST['Subfloor7']}</Subfloor7> <Subfloor8>{$_POST['Subfloor8']}</Subfloor8> <Subfloor9>{$_POST['Subfloor9']}</Subfloor9> <Subfloor10>{$_POST['Subfloor10']}</Subfloor10> </Subfloor> <Area> <Area1>{$_POST['Area']}</Area1> <Area2>{$_POST['Area2']}</Area2> <Area3>{$_POST['Area3']}</Area3> <Area4>{$_POST['Area4']}</Area4> <Area5>{$_POST['Area5']}</Area5> <Area6>{$_POST['Area6']}</Area6> <Area7>{$_POST['Area7']}</Area7> <Area8>{$_POST['Area8']}</Area8> <Area9>{$_POST['Area9']}</Area9> <Area10>{$_POST['Area10']}</Area10> </Area> <WindowArea> <WindowArea1>{$_POST['Window_Area']}</WindowArea1> <WindowArea2>{$_POST['Window_Area2']}</WindowArea2> <WindowArea3>{$_POST['Window_Area3']}</WindowArea3> <WindowArea4>{$_POST['Window_Area4']}</WindowArea4> <WindowArea5>{$_POST['Window_Area5']}</WindowArea5> <WindowArea6>{$_POST['Window_Area6']}</WindowArea6> <WindowArea7>{$_POST['Window_Area7']}</WindowArea7> <WindowArea8>{$_POST['Window_Area8']}</WindowArea8> <WindowArea9>{$_POST['Window_Area9']}</WindowArea9> <WindowArea10>{$_POST['Window_Area10']}</WindowArea10> </WindowArea> <WallLength> <WallLength1>{$_POST['Wall_Length']}</WallLength1> <WallLength2>{$_POST['Wall_Length2']}</WallLength2> <WallLength3>{$_POST['Wall_Length3']}</WallLength3> <WallLength4>{$_POST['Wall_Length4']}</WallLength4> <WallLength5>{$_POST['Wall_Length5']}</WallLength5> <WallLength6>{$_POST['Wall_Length6']}</WallLength6> <WallLength7>{$_POST['Wall_Length7']}</WallLength7> <WallLength8>{$_POST['Wall_Length8']}</WallLength8> <WallLength9>{$_POST['Wall_Length9']}</WallLength9> <WallLength10>{$_POST['Wall_Length10']}</WallLength10> </WallLength> <DoorArea> <DoorArea1>{$_POST['Door_Area']}</DoorArea1> <DoorArea2>{$_POST['Door_Area2']}</DoorArea2> <DoorArea3>{$_POST['Door_Area3']}</DoorArea3> <DoorArea4>{$_POST['Door_Area4']}</DoorArea4> <DoorArea5>{$_POST['Door_Area5']}</DoorArea5> <DoorArea6>{$_POST['Door_Area6']}</DoorArea6> <DoorArea7>{$_POST['Door_Area7']}</DoorArea7> <DoorArea8>{$_POST['Door_Area8']}</DoorArea8> <DoorArea9>{$_POST['Door_Area9']}</DoorArea9> <DoorArea10>{$_POST['Door_Area10']}</DoorArea10> </DoorArea> <CeilingHeight> <CeilingHeight1>{$_POST['Ceiling_Height']}</CeilingHeight1> <CeilingHeight2>{$_POST['Ceiling_Height2']}</CeilingHeight2> <CeilingHeight3>{$_POST['Ceiling_Height3']}</CeilingHeight3> <CeilingHeight4>{$_POST['Ceiling_Height4']}</CeilingHeight4> <CeilingHeight5>{$_POST['Ceiling_Height5']}</CeilingHeight5> <CeilingHeight6>{$_POST['Ceiling_Height6']}</CeilingHeight6> <CeilingHeight7>{$_POST['Ceiling_Height7']}</CeilingHeight7> <CeilingHeight8>{$_POST['Ceiling_Height8']}</CeilingHeight8> <CeilingHeight9>{$_POST['Ceiling_Height9']}</CeilingHeight9> <CeilingHeight10>{$_POST['Ceiling_Height10']}</CeilingHeight10> </CeilingHeight> <HeatedAbove> <heatedabove1>{$_POST['Heated_Above']}</heatedabove1> <heatedabove2>{$_POST['Heated_Above2']}</heatedabove2> <heatedabove3>{$_POST['Heated_Above3']}</heatedabove3> <heatedabove4>{$_POST['Heated_Above4']}</heatedabove4> <heatedabove5>{$_POST['Heated_Above4']}</heatedabove5> <heatedabove6>{$_POST['Heated_Above6']}</heatedabove6> <heatedabove7>{$_POST['Heated_Above7']}</heatedabove7> <heatedabove8>{$_POST['Heated_Above8']}</heatedabove8> <heatedabove9>{$_POST['Heated_Above9']}</heatedabove9> <heatedabove10>{$_POST['Heated_Above10']}</heatedabove10> </HeatedAbove> <HeatedBelow> <heatedbelow1>{$_POST['Heated_Below']}</heatedbelow1> <heatedbelow2>{$_POST['Heated_Below2']}</heatedbelow2> <heatedbelow3>{$_POST['Heated_Below3']}</heatedbelow3> <heatedbelow4>{$_POST['Heated_Below4']}</heatedbelow4> <heatedbelow5>{$_POST['Heated_Below5']}</heatedbelow5> <heatedbelow6>{$_POST['Heated_Below6']}</heatedbelow6> <heatedbelow7>{$_POST['Heated_Below7']}</heatedbelow7> <heatedbelow8>{$_POST['Heated_Below8']}</heatedbelow8> <heatedbelow9>{$_POST['Heated_Below9']}</heatedbelow9> <heatedbelow10>{$_POST['Heated_Below10']}</heatedbelow10> </HeatedBelow> <QuoteBaseboard> <QuoteBaseboard1>{$_POST['Quote_Baseboard']}</QuoteBaseboard1> <QuoteBaseboard2>{$_POST['Quote_Baseboard2']}</QuoteBaseboard2> <QuoteBaseboard3>{$_POST['Quote_Baseboard3']}</QuoteBaseboard3> <QuoteBaseboard4>{$_POST['Quote_Baseboard4']}</QuoteBaseboard4> <QuoteBaseboard5>{$_POST['Quote_Baseboard5']}</QuoteBaseboard5> <QuoteBaseboard6>{$_POST['Quote_Baseboard6']}</QuoteBaseboard6> <QuoteBaseboard7>{$_POST['Quote_Baseboard7']}</QuoteBaseboard7> <QuoteBaseboard8>{$_POST['Quote_Baseboard8']}</QuoteBaseboard8> <QuoteBaseboard9>{$_POST['Quote_Baseboard9']}</QuoteBaseboard9> <QuoteBaseboard10>{$_POST['Quote_Baseboard10']}</QuoteBaseboard10> </QuoteBaseboard> <Glycol> <Glycol1>{$_POST['Glycol']}</Glycol1> <Glycol2>{$_POST['Glycol2']}</Glycol2> <Glycol3>{$_POST['Glycol3']}</Glycol3> <Glycol4>{$_POST['Glycol4']}</Glycol4> <Glycol5>{$_POST['Glycol5']}</Glycol5> <Glycol6>{$_POST['Glycol6']}</Glycol6> <Glycol7>{$_POST['Glycol7']}</Glycol7> <Glycol8>{$_POST['Glycol8']}</Glycol8> <Glycol9>{$_POST['Glycol9']}</Glycol9> <Glycol10>{$_POST['Glycol10']}</Glycol10> </Glycol> <DomesticHotWater>{$_POST['Domestic_Hot_Water']}</DomesticHotWater> <NumberOfShowers>{$_POST['Showers']}</NumberOfShowers> <SimultaneousShowers>{$_POST['Simultaneous_Showers']}</SimultaneousShowers> <NumberOfSinks>{$_POST['Sinks']}</NumberOfSinks> <Vanities>{$_POST['Vanities']}</Vanities> <Toilets>{$_POST['Toilets']}</Toilets> <Washers>{$_POST['Washers']}</Washers> <Spigots>{$_POST['Spigots']}</Spigots> "; $stringData = htmlspecialchars($stringData); fwrite($fh, $stringData); $stringData = "</project>\n"; fwrite($fh, $stringData); fclose($fh); ?>
  11. Hi everyone bit of a funny one, but im looking for someone who can help me with my PHP in the south of england / brighton & hove area, I am okay with php but I would like to further my skills and vice versa, I would be happy to offer help with other stuff if someone would like to benefit from me I code, bin/bash, I can create from asterisk IVR's or full asterisk phone systems, do networking, teach DNS, Can diagnose voip systems and even further down the line with termination, im pretty good at mysql, and also database migration and have really good knowledge of using rsync for massive advantages. These are just a few that come to mind
  12. If there are PHP developers who want to create a small project for learning purposes, you can join us here https://github.com/fastpress/docs
  13. Hi everyone, I need an advice about website and job. 1. which is better - Virtual Private Network or Shared-network (like GoDaddy.com). 2. what should I do If i want to have a job at web development - using coding or Adobe Dreamweaver CS6 or CC. I need to decide what is best for me to create my own website with PHP. I believe it is easier to create website with Adobe Dreamweaver, but I was told by experienced guy that Dreamweaver is no good to use, most companies are prefer to use using code than Dreamweaver. is that true? Please advise me. Thank you in advance time. Gary
  14. Hi everyone, I made script in php that working with HTML select and option, but I can't figure how to do that. Is any website that can provide tutorial about select and option with php database. I mean, for example, I set up the 12 months in the select, then drop menu to pick an option, I pick July, then click on submit, then php display the list of name who have birthday on July. Get it? Please ask me if you are not sure you understand what i mean... Thank you in advance time. Gary
  15. I have an exercise which I must complete, but thus far... I'm a bit stuck and don't know if I have made the correct code array? Question: Start with the following code: $array = array ('2' => 1, 3); Without making a new array, change the above array so that the key-value pairs are: 2 => 1 3 => 3 b => 4 4 => 2 I don't think this code (as below) is correct because of the commas in the number sequence... I'm guessing it should be 21, 33, b4, 42? <?php $array = array ('2' => 1, 3 => 3, b => 4, 4 => 2); foreach($array as $key=>$val) { echo" $key, $val"; } ?> Output: 2, 1 3, 3 b, 4 4, 2.
  16. Hi all. I don't know why this is happening. I have a scrip that backs up database. It works fine on database1 but when i use it on database2, it throws an error? Fatal error: Call to a member function fetch_row() on a non-object in $tableshema = $shema->fetch_row() ; both databases are on same domain. ps: even with another backup script still throws an error in database2 thanks ##################### //CONFIGURATIONS ##################### // Define the name of the backup directory define('BACKUP_DIR', 'cashBackup' ) ; // Define Database Credentials define('HOST', 'localhost' ) ; define('USER', 'username' ) ; define('PASSWORD', 'password' ) ; define('DB_NAME', 'database2' ) ; /* Define the filename for the Archive If you plan to upload the file to Amazon's S3 service , use only lower-case letters . Watever follows the "&" character should be kept as is , it designates a timestamp , which will be used by the script . */ $archiveName = 'mysqlbackup--' . date('d-m-Y') . '@'.date('h.i.s').'&'.microtime(true) . '.sql' ; // Set execution time limit if(function_exists('max_execution_time')) { if( ini_get('max_execution_time') > 0 ) set_time_limit(0) ; } //END OF CONFIGURATIONS /* Create backupDir (if it's not yet created ) , with proper permissions . Create a ".htaccess" file to restrict web-access */ if (!file_exists(BACKUP_DIR)) mkdir(BACKUP_DIR , 0700) ; if (!is_writable(BACKUP_DIR)) chmod(BACKUP_DIR , 0700) ; // Create an ".htaccess" file , it will restrict direct access to the backup-directory . $content = 'deny from all' ; $file = new SplFileObject(BACKUP_DIR . '/.htaccess', "w") ; $written = $file->fwrite($content) ; // Verify that ".htaccess" is written , if not , die the script if($written <13) die("Could not create a \".htaccess\" file , Backup task canceled") ; // Check timestamp of the latest Archive . If older than 24Hour , Create a new Archive $lastArchive = getNameOfLastArchieve(BACKUP_DIR) ; $timestampOfLatestArchive = substr(ltrim((stristr($lastArchive , '&')) , '&') , 0 , - ; if (allowCreateNewArchive($timestampOfLatestArchive)) { // Create a new Archive createNewArchive($archiveName) ; } else { echo '<p>'.'Sorry the latest Backup is not older than 24Hours , try a few hours later' .'</p>' ; } ########################### // DEFINING THE FOUR FUNCTIONS // 1) createNewArchive : Creates an archive of a Mysql database // 2) getFileSizeUnit : gets an integer value and returns a proper Unit (Bytes , KB , MB) // 3) getNameOfLastArchieve : Scans the "BackupDir" and returns the name of last created Archive // 4) allowCreateNewArchive : Compares two timestamps (Yesterday , lastArchive) . Returns "TRUE" , If the latest Archive is onlder than 24Hours . ########################### // Function createNewArchive function createNewArchive($archiveName){ $mysqli = new mysqli(HOST , USER , PASSWORD , DB_NAME) ; if (mysqli_connect_errno()) { printf("Connect failed: %s", mysqli_connect_error()); exit(); } // Introduction information $return = "--\n"; $return .= "-- A Mysql Backup System \n"; $return .= "--\n"; $return .= '-- Export created: ' . date("Y/m/d") . ' on ' . date("h:i") . "\n\n\n"; $return .= "--\n"; $return .= "-- Database : " . DB_NAME . "\n"; $return .= "--\n"; $return .= "-- --------------------------------------------------\n"; $return .= "-- ---------------------------------------------------\n"; $return .= 'SET AUTOCOMMIT = 0 ;' ."\n" ; $return .= 'SET FOREIGN_KEY_CHECKS=0 ;' ."\n" ; $tables = array() ; // Exploring what tables this database has $result = $mysqli->query('SHOW TABLES' ) ; // Cycle through "$result" and put content into an array while ($row = $result->fetch_row()) { $tables[] = $row[0] ; } // Cycle through each table foreach($tables as $table) { // Get content of each table $result = $mysqli->query('SELECT * FROM '. $table) ; // Get number of fields (columns) of each table $num_fields = $mysqli->field_count ; // Add table information $return .= "--\n" ; $return .= '-- Tabel structure for table `' . $table . '`' . "\n" ; $return .= "--\n" ; $return.= 'DROP TABLE IF EXISTS `'.$table.'`;' . "\n" ; // Get the table-shema $shema = $mysqli->query('SHOW CREATE TABLE '.$table) ; // Extract table shema $tableshema = $shema->fetch_row() ; // Append table-shema into code $return.= $tableshema[1].";" . "\n\n" ; // Cycle through each table-row while($rowdata = $result->fetch_row()) { // Prepare code that will insert data into table $return .= 'INSERT INTO `'.$table .'` VALUES ( ' ; // Extract data of each row for($i=0; $i<$num_fields; $i++) { $return .= '"'.$rowdata[$i] . "\"," ; } // Let's remove the last comma $return = substr("$return", 0, -1) ; $return .= ");" ."\n" ; } $return .= "\n\n" ; } // Close the connection $mysqli->close() ; $return .= 'SET FOREIGN_KEY_CHECKS = 1 ; ' . "\n" ; $return .= 'COMMIT ; ' . "\n" ; $return .= 'SET AUTOCOMMIT = 1 ; ' . "\n" ; //$file = file_put_contents($archiveName , $return) ; $zip = new ZipArchive() ; $resOpen = $zip->open(BACKUP_DIR . '/' .$archiveName.".zip" , ZIPARCHIVE::CREATE) ; if( $resOpen ){ $zip->addFromString( $archiveName , "$return" ) ; } $zip->close() ; $fileSize = getFileSizeUnit(filesize(BACKUP_DIR . "/". $archiveName . '.zip')) ; $message = <<<msg <h4>BACKUP completed ,</h4> <p> The backup file has the name of : <strong> $archiveName </strong> and it's file-size is : $fileSize. </p> <p> This zip archive can't be accessed via a web browser , as it's stored into a protected directory.<br> It's highly recomended to transfer this backup to another filesystem , use your favorite FTP client to download the file . </p> msg; echo $message ; } // End of function creatNewArchive // Function to append proper Unit after a file-size . function getFileSizeUnit($file_size){ switch (true) { case ($file_size/1024 < 1) : return intval($file_size ) ." Bytes" ; break; case ($file_size/1024 >= 1 && $file_size/(1024*1024) < 1) : return round(($file_size/1024) , 2) ." KB" ; break; default: return round($file_size/(1024*1024) , 2) ." MB" ; } } // End of Function getFileSizeUnit // Funciton getNameOfLastArchieve function getNameOfLastArchieve($backupDir) { $allArchieves = array() ; $iterator = new DirectoryIterator($backupDir) ; foreach ($iterator as $fileInfo) { if (!$fileInfo->isDir() && $fileInfo->getExtension() === 'zip') { $allArchieves[] = $fileInfo->getFilename() ; } } return end($allArchieves) ; } // End of Function getNameOfLastArchieve // Function allowCreateNewArchive function allowCreateNewArchive($timestampOfLatestArchive , $timestamp = 24) { $yesterday = time() - $timestamp*3600 ; return ($yesterday >= $timestampOfLatestArchive) ? true : false ; } // End of Function allowCreateNewArchive
  17. I have to declare an array which contains the sentence 'Programming in PHP is fun!' and which also contains the words of the sentence separately. I have the following code but the end sentence has a zero - how do I get rid of that, moreover, how do I put a line break in between the line 'fifth word fun! and Programming in PHP is fun! <?php $fun = [ 'First Word' => 'Programming', 'Second Word' => 'in', 'Third Word' => 'PHP', 'Fourth Word' => 'is', 'Fifth Word' => 'fun!', 'Programming in PHP is fun!' ]; foreach($fun as $key=>$val) { echo" $key, $val</br>";} ?> Output: First Word, ProgrammingSecond Word, inThird Word, PHPFourth Word, isFifth Word, fun!0, Programming in PHP is fun!
  18. I do have a list of categories and its sub categories, something like this. INSERT INTO categories VALUES (1,NULL, 'Products', NULL), (2,1, 'Computers', NULL), (3,2, 'Laptops', NULL), (4,2, 'Desktop Computers', NULL), (5,2, 'Tab PCs', NULL), (6,2, 'CRT Monitors', NULL), (7,2, 'LCD Monitors', NULL), (8,2, 'LED Monitors', NULL), (9,1, 'Mobile Phones', NULL), (10,9, 'LG Phone', NULL), (11,9, 'Anroid Phone', NULL), (12,9, 'Windows Mobile', NULL), (13,9, 'iPad', NULL), (14,9, 'Samsung Galaxy', NULL), (15,1, 'Digital Cameras', NULL), (16,1, 'Printers and Toners', NULL); Now I need to create a Product sub and sub-sub menu using this product list. This is my expecting Markup for the menu. --- --- --- <li class="current-menu-item menu-item-has-children"> <a href="#">Products</a> <ul class="sub-menu"> <li> <a href="#">Laptops & Desktop Monitors</a> <ul class="sub-menu"> <li"><a href="products.php&product-id=5">Category 1</a></li> <li"><a href="products.php&product-id=6">Category 2</a></li> <li"><a href="products.php&product-id=7">Category 3</a></li> </ul> </li> <li><a href="products.php&product-id=4">Mobile Phones</a></li> <li><a href="products.php&product-id=4">Phones Accessories</a></li> <li><a href="products.php&product-id=4">Computer accessories</a></li> </ul> </li> --- --- --- So I tried it using recursion as @Barand showed me in earlier post. $prep_stmt = "SELECT category_id , name , IFNULL(parent, 0) FROM categories ORDER BY name"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt) { // Execute the prepared query. $stmt->execute(); $stmt->store_result(); $numrows = $stmt->num_rows; if ($numrows >= 1) { // get variables from result. $stmt->bind_result($id, $name, $parent); // Fetch all the records: while ($stmt->fetch()) { $cats[$parent][$id] = $name; } // Close the statement: $stmt->close(); unset($stmt); } } <?php // ------- Display Category List -------- function displayList(&$cats, $parent, $level=0) { switch ($level) { case 0: $class = "sub-menu"; break; case 1: $class = "sub-menu"; break; case 2: $class = "children2"; break; } if ($parent==0) { foreach ($cats[$parent] as $id=>$nm) { displayList($cats, $id); } } else { echo "<ul class='$class'>\n"; foreach ($cats[$parent] as $id=>$nm) { echo "<li><a href='products.php?product=$id'>$nm</a></li>\n"; if (isset($cats[$id])) { displayList($cats, $id, $level+1); //increment level } } echo "</ul>\n"; } } displayList($cats, 0); ?> It display my sub menu correctly but not displaying sub sub menu. This is the rendering HTML from above code. <li> <a href="">Products</a> <ul class='sub-menu'> <li><a href='products.php?product=22'>Computer Accessaries</a></li> <ul class='sub-menu'> <li><a href='products.php?product=24'>Network Cables</a></li> <li><a href='products.php?product=23'>USB Cables</a></li> </ul> <li><a href='products.php?product=2'>Computers</a></li> <ul class='sub-menu'> <li><a href='products.php?product=6'>CRT Monitors</a></li> <li><a href='products.php?product=4'>Desktop Computers</a></li> <li><a href='products.php?product=3'>Laptops</a></li> <li><a href='products.php?product=7'>LCD Monitors</a></li> <li><a href='products.php?product=8'>LED Monitors</a></li> <li><a href='products.php?product=5'>Tab PCs</a></li> </ul> <li><a href='products.php?product=15'>Digital Cameras</a></li> <ul class='sub-menu'> <li><a href='products.php?product=21'>test</a></li> </ul> <li><a href='products.php?product=18'>test2</a></li> <li><a href='products.php?product=19'>test3</a></li> </ul> </li> Can anybody tell me how to fix this problem? Thank you.
  19. Hi all. I have a script that i want to run in a cronjob. but i dont know why it's not running. i am using godaddy cpanel ps: when i visit the url of the file, it works as expected, and also when i run it via a form button, it works also. what could be the problem? below is the command i used: /usr/local/bin/php -q /home/username/directory/directory/file-name.php thanks
  20. Hi, Is that possible to connect to microsoft sql server by using mysqli? Currently i connected by using sqlsrv. For example, $serverName = "servername.com"; //serverName\instanceName $connectionInfo = array("Database" => "DB1", "UID" => "user99", "PWD" => "12345"); $conn = sqlsrv_connect($serverName, $connectionInfo); i have try quite some time to use mysqli to connect. But I keep getting errors.. Thank You
  21. Hi all, I was hoping you could point me in the right direction, I have 2 questions. 1. I want to have an option drop down which uses the array of a returned sql query. I have the following code which uses onchange to submit the selection, how do I use the mysql_fetch_array($result1) to give a list of the two selected columns in the $Site=array() bit. 2. The selected result will be used in more SQL select statements, so once a site from the list is selected the relevant data from other tables will be displayed using e.g. select person from people [some inner join statement] where site="site 1"; Therefore the $_POST value must be available to be passed to other queries once selected. Thanks for any help, I still feel like a noob, but I'm getting there. Gary <?php include 'header.php'; ?> <div class='container'> <?php include 'menu.php'; ?> <?php include 'connect.php'; ?> <?php $sql1="SELECT Sites.Site_ID, Sites.Site_name_1 FROM `Sites`"; $result1=mysql_query($sql1); ?> <?php function get_options() { $site=array('Site 1'=>'Site 1', 'Site 2'=>'Site 2', 'Site 3'=>'Site 3'); $options=''; while(list($k,$v)=each($site)) { $options.='<option value="'.$v.'">'.$k.'</option>'; } return $options; } if(isset($_POST['site'])) { echo $_POST['site']; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <select name="site" onchange="this.form.submit();"> <?php echo get_options(); ?> </select>
  22. Hi, how to generate auto increment ID with combination of characters and number. For example, i would like to have product ID start from PROD00001. When i add second product, the ID will check on the existing database to check PROD00001 is the latest ID. So, the second product ID will +1, become PROD00002.
  23. I am trying to take specific dates out of a csv file. Currently I am able to retrieve and display the data with the following code: $url = "http://ichart.finance.yahoo.com/table.csv?s=" . $row2['Symbol']; echo "<html><body><table border=1>"; $f = fopen($url, "r"); $fr = fread($f, filesize($url)); fclose($f); $ch = curl_init(); $timeout = 30; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); echo $row2['Symbol']; $lines = array(); $lines = explode("\n",$data); for($i=0;$i<count($lines);$i++) { echo "<tr>"; $cells = array(); $cells = explode(",",$lines[$i]); for($k=0;$k<count($cells);$k++) { echo "<td>".$cells[$k]."</td>"; } // for k end echo "</tr>"; } // for i end echo "</table></body></html>"; Can I set the script to only grab dates that are on the first of the month or do I have to create a new table and store the information? I guess I dont understand how I would make a variable to be equal to the date column since it is in a csv file.
  24. // Setup Variables $query = "SELECT Symbol, `Completion Date`, COUNT(Symbol) FROM CleanedCalendar GROUP BY Symbol,`Completion Date`"; $result2 = mysql_query($query) or die(mysql_error()); // Print out result while($row2 = mysql_fetch_array($result2)){ echo "There are ". $row2['COUNT(Symbol)'] ." ". $row2['Symbol'] ." items." . " ". $row2['Completion Date']; echo "<br />"; } The following code sorts my entire table. How would I make it only display the last 90 days? I tried adding WHERE STR_TO_DATE(`Completion Date`, '%W, %M %e, %Y') BETWEEN CURDATE() AND CURDATE() + INTERVAL (90) DAY;"; but it said I had the wrong syntax by where.
  25. Hi there guys, I've a little problem with inserting a file name into a database table. I can't see wich is the problem. The code is bellow and i think the problem is at INSERT INTO part. <?php $path = "./cv/"; $valid_formats = array("doc", "pdf"); if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") { $name = $_FILES['photoimg']['name']; $size = $_FILES['photoimg']['size']; if(strlen($name)) { list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats)) { if($size<(20480*20480)) // Image size max 20 MB { $actual_image_name = time().$id.".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; if(move_uploaded_file($tmp, $path.$actual_image_name)) { mysqli_query($mysqli,"INSERT INTO formular_client (client_cv = '$actual_image_name')"); } else echo "failed"; } else echo "Image file size max 20 MB"; } else echo "Invalid file format.."; } } ?> <input type="file" name="photoimg" id="photoimg" />
×
×
  • 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.