Jump to content

Search the Community

Showing results for tags 'echo'.

  • 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. Hello. What I have created is a menu with links. The links will display content on the page from a database. I have the links with id displayed, but nothing is displayed when the link is clicks. I have seen isset() and $_GET used but not a form and I don't know how to change the code to allow the display of data using ID. My site is local, and I am using XAMPP. The database connections work. This is my code: // query $query = "SELECT * FROM topmenu ORDER BY id ASC"; $row = $PDO->query($query); .... <table class="topmenu"> <tr> <td> <h1 class="siteName">site title</h1> </td> <?php foreach($row as $data) { ?> <td><a href="index.php?id=<?php echo $data['id']; ?>"> <?php echo $data['menuheader']; ?> </a></td> <?php } ?> </tr> </table> As a beginner, I would appreciate any help, no criticism of my code please! Also, is there a way of hiding the id in the url? Thanks in advance.
  2. I am trying to add a bootstrap class to php echo in mysql query but it doesn't work Here the code that I using $result = $conn->query($sql); echo ""; echo " New Users "; echo " "; echo ""; Any ides ?
  3. <?php function getFullMonthName($num) { if ($num < 1 || $num > 12) { return "Unknown"; } return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][$num - 1]; } $ids = mysqli_real_escape_string($db, $id); $sql = "SELECT * FROM multimedia, keertan WHERE multimedia.id LIKE '$ids' AND keertan.multimediaid LIKE '$ids' ORDER BY k_order ASC"; $result = mysqli_query($db, $sql); $title_list = "xyz"; $done = "xyz"; while ($myrow = mysqli_fetch_array($result)) { $location = $myrow["location"]; $program = $myrow["program"]; $year = sprintf("%04s", $myrow["year"]); $month = sprintf("%02s", $myrow["month"]); $monthName = getFullMonthName($month); $isnew = $myrow["isnew"]; if ($done != "true") { echo "<h3><b>$location $program $monthName $year</b></h3>"; } $done = "true"; while ($title_list != $myrow["title"]) { $title_list = $myrow["title"]; $sublist = $myrow["sub_title"]; echo "<div class=\"panel panel-primary\"><div class=\"panel-heading clickable\"><h3 class=\"panel-title\"><b>$title_list</b></h3>"; echo "<small>$sublist</small><span class=\"pull-right\"><i class=\"fa fa-minus\"></i></span></div><div class=\"panel-sarabveer-table\"><table class=\"table\"><thead><tr><th>Time</th><th>Kirtani</th><th>MP3</th><th>Video</th></thead>"; } if (strtotime($myrow["created"]) > strtotime("3 weeks ago")) { $newed = "NEW"; } elseif (strtotime($myrow["modified"]) > strtotime("3 weeks ago")) { $newed = "UPDATED"; } else { $newed = ""; } printf("<tr><td>%s</td><td>%s <small>%s</small></td>", $myrow["length"], $myrow["keertaneeya"], $newed); $mp3f = urlencode($myrow['mp3_link']); if ($myrow["mp3_link"] != "") { printf("<td><a target=\"_blank\" href=\"http://www.akji.org.uk/multimedia/%s/%s/%s\"><img src=\"images/play.png\" border=\"0\" width=\"25\" height=\"25\"></a></td>", $myrow["location"], $year, $mp3f); } else { echo "<td></td>"; } if ($myrow["rv1_link"] != "") { printf("<td><a target=\"_blank\" href=\"%s\"><img src=\"images/vplay.png\" border=\"0\" width=\"25\" height=\"25\"></a></td></tr>", $myrow["rv1_link"]); } else { echo "<td></td></tr>"; } echo "</table></div></div>"; } ?> So Basically I have this code that displays this page: https://akjmobile.org/keertannew.php?id=532 The problem is that the echo on line 97 runs to early and cuts of rest of the table information, making the other table information be spit out outside of the Bootstrap Panel. How would I fix this?
  4. foreach($text as $key => $value) { echo "test"; echo "value: " . $value . "<br />"; $tab=explode("\t", trim($value)); echo "<br />" . $tab[0] . $tab[$i1] . $tab[$i2] . $tab[$i3] . $tab[$i4] . $tab[$i5]. "<br />"; ... So this snippet is driving me mad. I'm trying to clean up some code that I've been working on in order to move on to the next segment. When I comment out the "echo value . $value" line, the whole thing 500's on me. I added in the echo test statement just to see if there was something weird going on with the open brace in the foreach statement. Does anyone have any idea why this would be acting this way. More code available upon request, but literally all I'm doing in between saves is adding a // in front of the word echo (I've tried at the very front of the line as well as directly in front of the e in echo with the same results). Thanks.
  5. I'm making my own CMS for my company so going through making the pages for the back end. What I want to do that I'm stuck on is -------------- I want to allow the user to specify how many input text fields they want shown on the page. I'm thinking that they could write a number then click submit, send the data to the same page (PHP self or action blank) and then the required amount of input fields would be echoed out. Echoing out is easy, I want to know how to find out how many fields are required, and then process it. Thanks in advance.
  6. Hi I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems. 1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that? for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; } I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } } If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; You may need this lines to: $selected_file = $_POST['radio1']; // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; Help would be very much appreciated.
  7. Hi I echo out images from a folder. The problem is that I have a html file in the same folder but I don't want to echo that out. How can I write my code to get rid of the html in the output? Here my code: <?php $filetype = '*.html'; $dirname = substr('$filetype'); $i=0; if (isset($_POST['submit2'])) { //get the dir from POST $selected_dir = $_POST['myDirs']; //now get the files from within the selected dir and echo them to the screen foreach(glob($selected_dir . DIRECTORY_SEPARATOR . '*') as $dirname) { echo substr($dirname, 0, -4); echo '<img src="'.$dirname.'" />'; echo "<label><div class=\"radiobt\"><input type='radio' name='radio1' value='$i'/></div></label>"; } } ?> P.S. when I echo out : substr($dirname, 0, -4); I want to get ride of the html filename there too. How can I do so something like this?
  8. i have proof, hold on. In PHP there are two basic ways to get output: echo and print. meant there was more ways but they werent basic.
  9. I registered a few days ago for help on this thread but didn't post again on it now because it has been marked answered and I thought I'd better not bump it. I received help in a way that has been the most encouraging since I began my calendar project. I'm wondering, though, if you would help me understand why I'm not successful at implementing the advice to the point that events are inserting into my calendar. My testing database has only one table: events and in events, only two columns (other than id): "startdt" and "description". This is a screenshot of how the table's columns are set upL This is a screenshot of the table content: This is my code with the edits added from the support thread: <?PHP $var = mysql_real_escape_string($_GET['startdt, description']); $con=mysql_connect("localhost","user","password"); // Check connection if (mysql_connect_error()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //select a database to work with $selected = mysql_select_db("mydatabase_",$con) or die("Could not select mydatabase_"); //execute the SQL query and return records $result = mysql_query("SELECT information FROM events WHERE value='$startdt', 'description'"); //fetch tha data from the database while ($row = mysql_fetch_array($result)) { echo $row{'startdt, description'}; } //close the connection mysql_close($con); ?> <!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" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <?php $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $prevMonth = $currMonth==1 ? 12 : $currMonth-1; $nextMonth = $currMonth==12? 1 : $currMonth+1; $prevYear = $currMonth==1 ? $currYear-1 : $currYear; $nextYear = $currMonth==12? $currYear+1 : $currYear; $day1 = mktime(0,0,0,$currMonth,1,$currYear); $dim = date('t', $day1); $dayN = mktime(0,0,0,$currMonth,$dim,$currYear); $dow1 = (date('w',$day1)+0) % 7; $dowN = (date('w',$dayN)+0) % 7; $calHead = date('F Y',$day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo "$d" ; echo "</td>\n"; } while ($c++ % 7 != 0) echo '<td class=\"hd\"> </td>'; echo "</tr></table>\n"; echo '</div></div>'; // calander entries. Use the date as the key (in YYYY/MM/DD format) $entries = array( '2014/8/16' => array( 'Event', ), ); for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo "$d" ; echo "</td>\n"; } // construct the date, this will be used to check to if the key exists in the $entries array $dateKey = "$currYear/$currMonth/$d"; // check if the key exists in the $entries array if(array_key_exists($dateKey, $entries)) { // for each event, list it in a seperate tool tip foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; } } ?> </body> </html> I am not getting any errors in the PHP Code Checker (although I am receiving the notice that these functions are now deprecated): mysql_close() mysql_connect() mysql_fetch_array() mysql_query() mysql_real_escape_string() mysql_select_db() When I upload my page to the server, everything seems fine, except that no information is added to the table. When I check the page source, I see this: <!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" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="/1cal/calendar.php?year=2014&month=7"> Prev </a></td> <td colspan="5" class="adjust">August 2014</td> <td class="hd"><a class="cal_button" href="/1cal/calendar.php?year=2014&month=9"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr><!--DEBUG: year=$currYear and month=$currMonth<hr/--><td class="hd"> </td><td class="hd"> </td><td class="hd"> </td><td class="hd"> </td><td class="hd"> </td><td class="we" > 1</td> <td class="we" > 2</td> </tr><tr><td class="wd" > 3</td> <td class="wd" > 4</td> <td class="wd" > 5</td> <td class="wd" > 6</td> <td class="wd" > 7</td> <td class="we" > 8</td> <td class="we" > 9</td> </tr><tr><td class="wd" > 10</td> <td class="wd" > 11</td> <td class="wd" > 12</td> <td class="wd" > 13</td> <td class="wd" > 14</td> <td class="we" style='padding: 0px;'> 15</td> <td class="we" > 16</td> </tr><tr><td class="wd" > 17</td> <td class="wd" > 18</td> <td class="wd" > 19</td> <td class="wd" > 20</td> <td class="wd" > 21</td> <td class="we" > 22</td> <td class="we" > 23</td> </tr><tr><td class="wd" > 24</td> <td class="wd" > 25</td> <td class="wd" > 26</td> <td class="wd" > 27</td> <td class="wd" > 28</td> <td class="we" > 29</td> <td class="we" > 30</td> </tr><tr><td class="wd" > 31</td> <td class=\"hd\"> </td><td class=\"hd\"> </td><td class=\"hd\"> </td><td class=\"hd\"> </td><td class=\"hd\"> </td><td class=\"hd\"> </td></tr></table> </div></div></body> </html> I don't have an understanding of what the Debug is telling me although I note the number "1" within the tag and find that interesting because on those occasions, earlier today, when the file upload would result in a white page, viewing the page source would reveal nothing but the numeral "1" in the upper left top. Are the deprecated functions enough to cause the event not to insert into the calendar? I'd appreciate any help in sorting why I'm not succeeding. As you see so often around here, I'm not a coder. I'm just forced into a position to have to fend for myself, as of late, and so I'm trying to learn what I can. Thank you for any help.
  10. Hi. I'm trying to achieve a calendar that only uses PHP and CSS. I registered today to ask for help (because I'm not a coder; I'm just another clueless musician). My goal is to just skip the database, altogether. I've already, so far, skipped the Javascript, as well. I have an HTML non-functioning mockup HERE that's a bit "off" cosmetically, but I'm just using it as an example. It has a made-up "event" on August 16. I'm just using a little "tooltip" CSS. (I have no idea how it works in IE, it's just me and my MacBook here, but still... you get the idea of the function.) Or I might use THIS to get it to work for IOS, but that needs a little aesthetic work. Not tinkering with all that today. Now... my PHP created calendar, that I will actually be using, is HERE. All the structure of the calendar is echoed in PHP so there is no actual HTML hard coding of table cells. In fact, the only HTML within the body is <body></body> So, I can't very well just pick a date and type in some tags and be off. My question is this (and because I don't really know correct PHP jargon to formulate a question, I'm not being successful at Googling): Is it possible to use PHP to isolate a specific date, say, in this case, August 16 2014, and then, based upon that date existing, echo what I have hard-coded into the mockup example: <div class="has-tooltip"> Event <span class="tooltip">Concert In The Park<br /> 123 City Park Drive<br /> AnyTown, STATE 00000<br /> <a href="http://example.com" target="_blank">More Info</a><br /> or call 555.123.4567<br /></span> </div> I realize that this means that there's always a great chance of error, but this wouldn't be a calendar with any other users inserting dates; it's nothing more than an occasional event and then it's over, and I would be the one posting the events, so I'd be able to test it before publishing it. Possible? And if so, would you advise as how to get PHP to isolate a particular date and then echo the HTML and, of course, have it reside in the date-appropriate table cell? (I've managed to echo HTML to build the calendar structure, but I've never created an echo in conjunction with calling for a specific date. I'd appreciate any help and thanks so much. PHP: <?php $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $prevMonth = $currMonth==1 ? 12 : $currMonth-1; $nextMonth = $currMonth==12? 1 : $currMonth+1; $prevYear = $currMonth==1 ? $currYear-1 : $currYear; $nextYear = $currMonth==12? $currYear+1 : $currYear; $day1 = mktime(0,0,0,$currMonth,1,$currYear); $dim = date('t', $day1); $dayN = mktime(0,0,0,$currMonth,$dim,$currYear); $dow1 = (date('w',$day1)+0) % 7; $dowN = (date('w',$dayN)+0) % 7; $calHead = date('F Y',$day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[php_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[php_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo "$d" ; echo "</td>\n"; } while ($c++ % 7 != 0) echo '<td class=\"hd\"> </td>'; echo "</tr></table>\n"; echo '</div></div>'; ?>
  11. Hi everyone, On our school website, we've got a page where students can do a quiz, and get feedback given to them, as to whether their answers are correct or incorrect. The code echos the student response for each question, and the feedback, tick / cross is displayed in the adjacent column. However, I've just changed the input box from a text field to a text area, and I've noticed a little quirk. The student answer, after pressing submit, now displays in lower case. Is their any way I can echo their answer, exactly as they input it. Here is the relevant code: <textarea name="user_answer_<?=$row_counter?>" cols="40" rows="2" /><?=$userAnswer?></textarea> Thanks for your time, Dave
  12. Hello Php Friends, I have this search code, it wents well but i want to add and echo or maybe a script that woul tell "NO RESULTS FOUND" in case the search does not found data in the database. Please anyone can help. include 'Connect.php'; //Connect to MySQL Server mysql_connect($host, $dbusername, $dbpassword); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query $first_name = $_GET['first_name']; // Escape User Input to help prevent SQL Injection $first_name = mysql_real_escape_string($first_name); $query = "SELECT * FROM student_information WHERE first_name = '$first_name'"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = "<table border='1' cellpadding='10' cellspacing='1' align='center'>"; $display_string .= "<tr align='center'>"; $display_string .= "<th>LR Number</th>"; $display_string .= "<th>F i r s t N a m e</th>"; $display_string .= "<th>L a s t N a m e</th>"; $display_string .= "<th>Grade</th>"; $display_string .= "<th>Section</th>"; $display_string .= "<th>View</th>"; $display_string .= "<th>Update</th>"; $display_string .= "<th>Delete</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[LRN]</td>"; $display_string .= "<td>$row[first_name]</td>"; $display_string .= "<td>$row[last_name]</td>"; $display_string .= "<td>$row[grade]</td>"; $display_string .= "<td>$row[section]</td>"; $display_string .= "<td><a href='View_Profile.php?id=$student_id'>View</a> </td>"; $display_string .= "<td><a href='Admin_Edit_Student_Info.php?id=$student_id'>Update</a></td>"; $display_string .= "<td><a href='Delete.php?id=$student_id'>Delete</a></td>"; } $display_string .= "</table>"; echo $display_string; ?> Kindly tell me what codes i am missing and where exactly to put it.
  13. Hello, i have a question about how to change from database a row wich contains the duration of videos. I have videos with time in table row duration like this here below: Table: Duration 5:00 300 this should be like this > 3:00 < min 10:00 2000 this should be like this > 20:00 < 20 min 10000 this should be like this > 1:00:00 < 1 hour and so on. But when i echo out it show me like in the table row exactly. here is an exmple of my scrip: <?php $thumbs = $runrows ['thumbs']; $title = $runrows ['title']; $url = $runrows ['url']; $duration = $runrows ['duration']; while($runrows = mysql_fetch_assoc($getquery)) { echo '<li class="thumbcontent"><a href="'. $runrows['url'] .'" ><img src="'. $runrows['thumbs'].'" class="thumb" name="'. $runrows['title'] .'" alt="'. $runrows['title'] .'" title="'. $runrows['title'] .'" width="240" height="180" /> </a> <span class="duration">'. $runrows['duration'].'</span></li> '; } echo "<center>"; ?> And this is what a friend send me to check out but i cant figure out how to fit this code with my own code. <?php foreach (array(500, 234, 1100, 520, 1300, 10000) as $number) { echo $number, "\t"; $number = str_pad($number, 6, 0, STR_PAD_LEFT); echo ltrim($number{0}.$number{1}.':'.$number{2}.$number{3}.':'.$number{4}.$number{5}, ":0"), "\n"; } or this: foreach (['500', '234', '1100', '520', '1300', '10000'] as $number) { $time = strrev($number); $time = wordwrap($time, 2, ':', true); $time = strrev($time); echo "$number was transformed to $time\n"; } I hope i explained it well, i hope somebody can help me with a solution. Thanks in advance.
  14. Hello there, I am trying to recreate a HTML website on a WordPress website. On the current website we pull a php file from the directory that lists brands for different catrogies. http://www.nongmoshoppingguide.com/brands/feed-and-seed.html We use the following script <!--?php <br ?--> <?php include('../lib/IphoneDataRenderer.php');?> <?php echo $IphoneDataRenderer->getAdsForBrandId();?> <!--?php } ?--> <?php $IphoneDataRenderer listBrandsForCategory(); ?> and it works fine for the website above. However, when I add this code within our WP website we don't get any information (I did add the /lib/iphoneDataRenderer.php files and folders). Could you help me understand what I am doing wrong? Many thanks!
  15. Hello i have a question, i dont know if that is possible. I want to call a external page and echo like this below. index.php <?php include 'extern/connect.php'; $title = file_get_contents('extern/title.php'); ?> <head> <title><?php echo $title; ?></title> //here i want to echo also $a from title.php </head> Title.php <?php $a ="Youtube"; $b ="Facebook"; $c ="Myspace"; $d ="Google"; ?> Is that possible ? Thanks for any help
  16. I'm just a beginner with PHP. I created a PHP login system. Now I want to echo the username to the logged in user on the index.php page. Here's the code I have so far. It would be great if someone could suggest a way of doing this. Thanks! login.php <?php session_start(); require_once 'classes/Membership.php'; $membership = new Membership(); // If the user clicks the "Log Out" link on the index page. if(isset($_GET['status']) && $_GET['status'] == 'loggedout') { $membership->log_User_Out(); } // Did the user enter a password/username and click submit? if($_POST && !empty($_POST['username']) && !empty($_POST['pwd'])) { $response = $membership->validate_User($_POST['username'], $_POST['pwd']); } ?> <!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>Login</title> <link rel="stylesheet" type="text/css" href="css/default.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript" src="js/main.js"></script> </head> <body> <div id="login"> <form method="post" action=""> <h2>Login <small>enter your credentials</small></h2> <p> <label for="username">Username: </label> <input type="text" name="username" /> </p> <p> <label for="pwd">Password: </label> <input type="password" name="pwd" /> </p> <p> <input type="submit" id="submit" value="Login" name="submit" /> </p> </form> <?php if(isset($response)) echo "<h4 class='alert'>" . $response . "</h4>"; ?> </div><!--end login--> </body> </html> index.php (the page that the user is redirected to after logging in) <?php require_once 'classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); ?> <!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" /> <link rel="stylesheet" href="css/default.css" /> <!--[if lt IE 7]> <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script> <![endif]--> <title>Untitled Document</title> </head> <body> <div id="container"> <p> You have logged in. </p> <a href="login.php?status=loggedout">Log Out</a> </div><!--end container--> </body> </html> membership.php <?php require 'Mysql.php'; class Membership { function validate_user($un, $pwd) { $mysql = New Mysql(); $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; header("location: index.php"); } else return "Please enter a correct username and password"; } function log_User_Out() { if(isset($_SESSION['status'])) { unset($_SESSION['status']); if(isset($_COOKIE[session_name()])) setcookie(session_name(), '', time() - 1000); session_destroy(); } } function confirm_Member() { session_start(); if($_SESSION['status'] !='authorized') header("location: login.php"); } } mysql.php <?php require_once 'includes/constants.php'; class Mysql { private $conn; function __construct() { $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.'); } function verify_Username_and_Pass($un, $pwd) { $query = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1"; if($stmt = $this->conn->prepare($query)) { $stmt->bind_param('ss', $un, $pwd); $stmt->execute(); if($stmt->fetch()) { $stmt->close(); return true; } } } } Thanks a lot!
  17. I am wanting to echo a table if a field = x and if not echo another table. Can this be done easily? I have tried but not having much luck. Any help would be appreciated by this "on the fly" learner. Something like... IF AdviserCode=X then <table width="610" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="85">RCTI</td> <td width="85">Detail 1</td> <td width="85">Detail 2</td> <td width="85">Detail 3</td> <td width="85">Detail 4</td> <td width="85">Detail 5</td> </tr> <?php include("../edb.php"); $result=mysql_query("SELECT * FROM `afddocs_adviser_comm` WHERE AdviserCode =".$_SESSION['uid']." order by DateUploaded DESC"); while($test = mysql_fetch_array($result)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td><a class='".$test['RCTIcssclass']."'href =".$test['RCTIURL'].">".$test['RCTIImageType']."</a>"; echo"<td><a class='".$test['Detail1cssclass']."'href =".$test['Detail1URL'].">".$test['Detail1ImageType']."</a>"; echo"<td><a class='".$test['Detail2cssclass']."'href =".$test['Detail2URL'].">".$test['Detail2ImageType']."</a>"; echo"<td><a class='".$test['Detail3cssclass']."'href =".$test['Detail3URL'].">".$test['Detail3ImageType']."</a>"; echo"<td><a class='".$test['Detail4cssclass']."'href =".$test['Detail4URL'].">".$test['Detail4ImageType']."</a>"; echo"<td><a class='".$test['Detail5cssclass']."'href =".$test['Detail5URL'].">".$test['Detail5ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> OR (same table as above minus a couple of colums)
  18. Hey Guys, So i have a while loop bringing back some information for me from my database. pretty basic: $query = 'SELECT * from `db` WHERE `id` = '. $id; $run = mysql_query($query); while($rows = mysql_fetch_assoc($run)){ extract($rows); } Now in this loop i am trying to add a link using an anchor tag: echo '<a href="'.$domain . '">'.$domain.'</a><br>'; ( I WILL USE EXAMPLE LINK DONT CLICK BELOW FOR DEMO PURPOSES) which basically makes something like : http://ExampleLinkDontClick.com Now my issue is that for the life of me i cant understand why my link is being given and shown correctly, but the link is firing as so as you can see the anchor tag is looking for a page that i created or is on file in the directory, instead of going to the designated source of the url. any suggestions ? am i just missing something very basic ? usually this works flawlessly but maybe today is just one of those days .. lol thanks guys -justin7410
  19. Sorry if my wording/terminalogy on the discription is wrong. I'm new to PHP, so i'll do my best to detail what im trying to do. The PHP is doing what i need it to do. But i do not need to print the whole response. I only need the [address] and [pubkey] values as variables. I have read a few tutorials, but they assume i already know the strings to be converted to variables. Please help Code... <?php require_once 'jsonClient.php'; $service = new jsonClient('http://ooples:booples@127.0.0.1:18332/'); $apple = array ($service->validateaddress("1234567890")); print_r ($apple); ?> Response... Array ( [0] => Array ( [isvalid] => 1 [address] => 1234567890 [ismine] => 1 [isscript] => [pubkey] => hqwiuehf9 [iscompressed] => 1 [account] => foo ) )
  20. Hello, there. I've been messing around with this stuff recently and ran across this error when trying to output a message when not all login fields are filled in, as well as an error when trying to output a successful login message.. These parts of the code are: Check all fields filled: //get the form data $myusername = ($_POST['username']); $mypassword = ($_POST['password']); //check if all fields are filled in if ( (!$myusername) || (!mypassword) ) ) { echo "Please fill in all fields"; exit; } Check if user exists & log in: //check if user exists if ($account ==1) { $_SESSION["username"] = $myusername; $_SESSION["password"] = $mypassword; $_SESSION["userrecord"] = mysql_fetch_assoc($result); echo "You have been logged in successfully. Please click <a href=account.php>here</a> to continue."; } As you can probably tell from the title, the echo does not output onto the webpage. Any help is very much appreciated. Thanks.
  21. Hi, I am trying to customise some php code in a wordpress theme - the developer has left the planet and need to find a solution. This is the current code: <?php if ( $i < 3 ) { echo '<li class="margin_r"><div class="port_tn"><a href="'; echo the_permalink(); echo '" >'; echo the_post_thumbnail( array(40,40, true, "title" => "")); echo '</a> </div></li>'; $i= $i+"1"; } else { echo '<li class="no_margin"><div class="port_tn"><a href="'; echo the_permalink(); echo '" >'; echo the_post_thumbnail( array (40,40, true, "title" => "")); echo '</a> </div></li>'; $i = "0"; } ?> When the thumbnail is clicked it goes to the portfolio page. WHAT I WANT IT TO DO: I want it to open up the featured image of that portfolio post and open a pretty photo lightbox gallery instead. Skipping the single portfolio page. I then change the code to this code: <a href="<?php echo $image[0]; ?>" rel="prettyPhoto[portfolio-gallery]">'; echo the_post_thumbnail( array (40,40, true, "title" => "")); echo '</a> this now does skip the portfolip page and opens the prettyphoto lightbox, but then says it cant find the image or the url is incorrect. Please could you assist in amending the code to make this work the url of the website is: http://www.hayleyclarke.co.za/website/
  22. Greetings all, I have a question about escaping characters prior to entering a field into a database and than echo'ing that escaped data back onto a page. My problem is that the slash marks are echo'ing out of the database onto another page. For instance if I were to do something along the lines of: $hpintrotitle = mysqli_real_escape_string($connect, trim($_POST['hpintrotitle'])); $q = "UPDATE homepage SET mstitle='$hpintrotitle' WHERE msid='1' LIMIT 1"; $r = @mysqli_query($connect, $q); If I place the word "You've" or "Isn't" into that field when I echo it out from the database it comes back as "You\'ve" or "Isn\'t" I know this is probably basic stuff but I apparently missed this lesson in school. Any help would be appreciated. Side note: I am bringing this data back as an array using something along these lines: $rowintro = mysqli_fetch_array ($rintro, MYSQLI_NUM); echo $rowintro[0]; echo $rowintro[1]; and so on.... Thanks for taking a look.
  23. Hey, guys, I'm new in the whole php thing. I believe what I am asking here is super simple to do, I just wasn't able to find it anywhere. In the code below, you guys will notice that not all the fields show in every change of the dropdown menu TYPE, and, of course they don't, that's the whole point. I mean, I have arranged for each TYPE to have it's own fields. The thing is: how can I adapt for the html ECHO code to show ONLY the "labels", I mean, the pieces of HTML in the while($row = mysqli_fetch_array($result)), for the fields that were filled in? I mean, I don't want that in RESULT there are the "labels" of the fields whose values are there. <?php $con=mysqli_connect("localhost","root","","activitytest1"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (isset($_POST['submit'])) { $stmt = mysqli_prepare($con, "INSERT INTO activitytest1 (type, author, taskpre, taskdescription, outcome, semipre, semiwhile, exercisedescription, practicepre, practiceinstructions, leadin, gamepre, gameinstructions, videopre, videowhile, videopost, songpre, songwhile, songpost, mimioinstructions, otherinstructions, path, books, grouping, time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); mysqli_stmt_bind_param($stmt, 'sssssssssssssssssssssssss', $type, $author, $taskpre, $taskdescription, $outcome, $semipre, $semiwhile, $exercisedescription, $practicepre, $practiceinstructions, $leadin, $gamepre, $gameinstructions, $videopre, $videowhile, $videopost, $songpre, $songwhile, $songpost, $mimioinstructions, $otherinstructions, $path, $books, $grouping, $time); $type = $_POST['type']; $author = $_POST['author']; $taskpre = $_POST['taskpre']; $taskdescription = $_POST['taskdescription']; $outcome = $_POST['outcome']; $semipre = $_POST['semipre']; $semiwhile = $_POST['semiwhile']; $exercisedescription = $_POST['exercisedescription']; $practicepre = $_POST['practicepre']; $practiceinstructions = $_POST['practiceinstructions']; $leadin = $_POST['leadin']; $gamepre = $_POST['gamepre']; $gameinstructions = $_POST['gameinstructions']; $videopre = $_POST['videopre']; $videowhile = $_POST['videowhile']; $videopost = $_POST['videopost']; $songpre = $_POST['songpre']; $songwhile = $_POST['songwhile']; $songpost = $_POST['songpost']; $mimioinstructions = $_POST['mimioinstructions']; $otherinstructions = $_POST['otherinstructions']; $path = $_POST['path']; $books = $_POST['books']; $grouping = $_POST['grouping']; $time = $_POST['time']; $submit = $_POST['submit']; mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); } $result = mysqli_query($con,"SELECT * FROM activitytest1"); while($row = mysqli_fetch_array($result)) { echo "<table width='909' border='1' align='center' cellpadding='5' cellspacing='0'> <tr> <th width='125' scope='col'>Type</th> <th width='680' scope='col'>Description</th> <th width='120' scope='col'>Author</th> </tr></table> <br/> <table width='909' border='1' align='center' cellpadding='5' cellspacing='0'> <tr> <td width='125'>" . $row['type'] . "</th> <td width='680'>Time:" . $row['time'] . " min. <br><br>" . $row['books'] . "<br/>Grouping: " . $row['grouping'] . "<br/>Preview the Task:" . $row['taskpre'] . "<br/>Instructions:" . $row['taskdescription'] . "<br/>Outcome:" . $row['outcome'] . "<br/>Preview the semi-task:" . $row['semipre'] . "<br/>Instructions:" . $row['semiwhile'] . "<br/>Exercise Instructions: " . $row['exercisedescription'] . "<br/> Preview the Practice:" . $row['practicepre'] . "<br/>Practice Instructions:" . $row['practiceinstructions'] . "<br/>Lead-in:" . $row['leadin'] . "<br/>Preview the Game:" . $row['gamepre'] . "<br/>Game Instructions:" . $row['gameinstructions'] . "<br/>Song PRE:" . $row['songpre'] . "<br/>Song WHILE:" . $row['songwhile'] . "<br/>Song POST:" . $row['songpost'] . "<br/>Video PRE:" . $row['videopre'] . "<br/>Video WHILE:" . $row['videowhile'] . "<br/>Video POST:" . $row['videopost'] . "<br/>Mimio Instructions:" . $row['mimioinstructions'] . "<br/>Instructions:" . $row['otherinstructions'] . "<br/><br>Link/Path" . $row['path'] . "<br/></th> <td width='120'>" . $row['author'] . "</th> </tr></table> <br/> <hr size='1'/>"; } mysqli_close($con); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test 1</title> </head> <body> <br> <table width="909" border="1" align="center" cellpadding="5" cellspacing="0"> <tr> <th width="125" scope="col">Type</th> <th width="680" scope="col">Description</th> <th width="120" scope="col">Author</th> </tr></table> <br> <form action="index.php" method="POST"> <table width="909" border="1" align="center" cellpadding="5" cellspacing="0"> <td width="125"><label> </label> <select name="type" id="type" onChange="display(this,'Task','Semi-task','Practice','Exercise','Lead-in', 'Game', 'Video','Song','Mimio','Other');"> <option value="Unselected" selected="selected">Choose one:</option> <option value="Task">Task</option> <option value="Semi-task">Semi-task</option> <option value="Practice">Practice</option> <option value="Exercise">Exercise</option> <option value="Lead-in">Lead-in</option> <option value="Game">Game</option> <option value="Video">Video</option> <option value="Song">Song</option> <option value="Mimio">Mimio</option> <option value="Other">Other</option> </select></td> <td width="680"><div id="Task" style="display:none"> Task: <br /> Lead-in/Preview the task: <textarea name="taskpre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="taskdescription" cols="70" rows="2"></textarea> <br /> Outcome: <textarea name="outcome" cols="70" rows="2"></textarea> <br /> </div> <div id="Semi-task" style="display:none">Semi-task:<br /> Lead-in/Preview the task: <textarea name="semipre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="semiwhile" cols="70" rows="2"></textarea> <br /> </div> <div id="Exercise" style="display:none">Exercise:<br /> Instructions/Obs.: <textarea name="exercisedescription" cols="70" rows="2"></textarea> </div> <div id="Practice" style="display:none"> Practice:<br /> Lead-in/Preview the task: <textarea name="practicepre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="practiceinstructions" cols="70" rows="2"></textarea> <br /> </div> <div id="Lead-in" style="display:none"> Lead-in:<br> <textarea name="leadin" cols="70" rows="2"></textarea><br> </div> <div id="Game" style="display:none"> Game:<br /> Lead-in: <textarea name="gamepre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="gameinstructions" cols="70" rows="2"></textarea> </div> <div id="Video" style="display:none"> Video: <br /> Pre: <textarea name="videopre" cols="70" rows="2"></textarea> <br /> While: <textarea name="videowhile" cols="70" rows="2"></textarea> <br /> Post: <textarea name="videopost" cols="70" rows="2"></textarea> </div> <div id="Song" style="display:none"> Song: <br /> Pre: <textarea name="songpre" cols="70" rows="2"></textarea> <br /> While: <textarea name="songwhile" cols="70" rows="2"></textarea> <br /> Post: <textarea name="songpost" cols="70" rows="2"></textarea> </div> <div id="Mimio" style="display:none">Mimio:<br /> Instructions:<br> <textarea name="mimioinstructions" cols="70" rows="2"></textarea> </div> <div id="Other" style="display:none">Other:<br /> Instructions:<br> <textarea name="otherinstructions" cols="70" rows="2"></textarea><br /> </div> </td> <td width="120"><input name="author" type="text" size="12" maxlength="25" /></td> </tr> <tr> <td colspan="3"> <select name="books" id="Books"> <option value="books open" selected="selected">books open</option> <option value="books closed">books closed</option> </select> <br /> <select name="grouping"> <option value="individual" selected="selected">individual</option> <option value="pairs">pairs</option> <option value="trios">trios</option> <option value="groups of 3 to 4 students">groups of 3 to 4 students</option> <option value="groups of 5 students">groups of 5 students</option> <option value="divide the class into 2 groups">divide the class into 2 groups</option> <option value="divide the class into 3 groups">divide the class into 3 groups</option> <option value="divide the class into 4 groups">divide the class into 4 groups</option> </select> <br /> about <input name="time" type="text" id="Time" size="1" /> min </td> </tr> <tr> <td colspan="3">Link/Path: <input name="path" type="text" id="Path" size="40" /></td> </tr> <tr> <td colspan="3"><input type="submit" name="submit" value="Post!" /></td> </tr> </table> </form> </body> </html>
  24. Hey, i want the '***' to change depending on the length of the persons password. any way to echo a variable like this?
  25. i have been working on minor project this is login script of that page i am facing some problem i want to echo if user name password and category both 3 conditions dont match with error "wrong username/password" in form i have tried everything as per my knowledge please help me in this i am new to php so dont have much experience and knowledge of php <?php $msg=''; $con=mysql_connect('localhost','root',''); if(!$con) { die("Error While connecting......."); } else { mysql_select_db("sms",$con); if(isset($_POST['btnlog'])) { $res=mysql_query("select * from tbl_login where un='".$_POST['username']."' and pw='".$_POST['password']."' and cat='".$_POST['cat']."'"); while($r=mysql_fetch_array($res)) { mail("notification@receiver.com".$_POST['username']."Successfully Logged In"."From:notification@sender.com"); if($r['cat']=="admin") header("Location:admin/admin.php"); elseif($r['cat']=="faculty") header("Location:faculty/faculty.php"); else $msg="Incorrect Username/Password"; } } } ?> <body> <section class="login_container"> <div class="login_box"> <h1>Login</h1> <form method="post"> <center><?php echo $msg; ?></center> <p><input type="text" name="username" value="" placeholder="Username"></p> <p><input type="password" name="password" value="" placeholder="Password"></p> <center><select class="select" name="cat">Category <option selected="selected">Select A Category</option> <option value="admin">Administrator</option> <option value="faculty">Faculty</option> </select></center> <p class="submit"><input type="submit" name="btnlog" value="Login"> <input type="reset" value="Clear" /></p> </form> </div> </section>
×
×
  • 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.