PHP - Output Php Database To Html Webpage
i'm trying to get a php database to output/display on a html webpage
and have no results from cutting and pasting code from online tutorials i'm saving to a file with a htm extension i believe i have the connection data right: $db_host = 'server'; $db_user = 'username'; $db_pwd = 'password'; $database = 'database'; $table = 'table'; if (!mysql_connect($server,$username,$password)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $result = mysql_query("SELECT * FROM table") or die(mysql_error()); Can someone please help me? send code? tell me what i'm doing wrong? Thanks Similar TutorialsHi there, ths is my very first post to this site so thanks in advance for reading and suggesting. (And apologies if this is not correct forum) I have a website that generates some output ( onto website File A). I want to email this output that's generated to a users (inputted) email address. I cant quite work out how to get that output into the email. I can cut and paste (into $menu variable in file B) but i want to have it done automatically. So far i have the following code (and maybe there's an easier way/ better way), but this is what i have so far. in file A, I have the PHP/MySQL generated output and an "email" icon that displays ( <input type='image' onClick='myPopup()' img src='email1.jpg' alt='' width='100' height='100' vspace='5' border='10' align='left' ALT='Email' value='Email' /> ) this redirects to file B (which pops up and asks for the email address to send generated output of file A to) when user clicks email button.. It seems from my investigations so far that I somehow have to get it into $menu variable of file B but am unsure how, or if there is another way (to how i'm trying)? In IE7 under Page dropdown, there's an option to 'Send page by -Mail...' this is what i want mine to do Could someone have a look and see if there's something I could try - thanks very much file B = <html> <head> <link rel="stylesheet" type="text/css" media="all" href="style.css"/> <title> Email menu </title> </head> <body> <h3><p align="center"><u>Email menu & nutritional information</u></p></h3> <br><br><br> <?php echo "<br>"; echo "<br>"; echo "<br>"; ?> <p><font color="orangered" size="+1"><tt><b>*</b></tt></font> indicates a required field</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td align="right"> <p>Email </p> </td> <td> <input name="email" type="text" maxlength="50" size="40" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right" colspan="2"> <hr noshade="noshade" /> <input type="reset" value="Reset Form" /> <input type="submit" name="submitok" value="EMAIL menu" onClick="javascript:window.close();"/> </td> </tr> </table> <?php $menu="if i cut and paste file A content, it does send but i want automated"; if (isset($_POST['submitok'])){ $message = "Your menu and the nutritional information for that menu below $menu; Kind regards, "; mail($_POST['email'],"Your menu",$message); Header("Location: print_menu_restrict.php"); } ?> </body> </html> Hi, I have a webpage that the super administrator log's into. Once the super administrator is logged in he/she can view his/her clients. The super admins clients also have their own clients, once the super admins clients login they can view their own clients details who register with them. What i am trying to do is have a link on that clients name (for the super admins clients) that will bring me to a new page where i can edit his/her details that is stored in the mysql database. I have used INPUT buttons for each clients row in a FORM which works......but i know this is not the right way to do it. This is the code i have used to display the clients with the input button: <?php $query = "SELECT ID FROM clients WHERE username = '$username'"; $result = mysql_query($query); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)){ $userID = $row['ID']; $query = "SELECT * FROM users WHERE userID = '$userID'"; $result = mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="3" cellpadding="3" width="100%"> <tr> <th width="30%"><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Username</font></th> <th><font face="Arial, Helvetica, sans-serif">Email Address</font></th> <th> </th> </tr> <?php $i=0; while ($i < $num) { $userID=mysql_result($result,$i,"userID"); $name=mysql_result($result,$i,"name"); $username=mysql_result($result,$i,"username"); $email=mysql_result($result,$i,"email"); ?> <tr> <td width="30%"><?php echo $name; ?></td> <td><?php echo $username; ?></td> <td><?php echo $email; ?></td> <td><form action="http://localhost/single-client.php?userID=<?php echo $userID; ?>&name=<?php echo $name; ?>" method="post" style="margin:0px;"> <input type="hidden" name="selectuser" id="selectuser" value="<?php echo $userID; ?>" /><input type="hidden" name="username1" id="username1" value="<?php echo $username; ?>" /><input type="hidden" name="name1" id="name1" value="<?php echo $name; ?>" /><input type="submit" name="submit" value="View Info" class="button" /></form></td> </tr> <?php $i++; }}} ?> </table> From the above code when i use the following code: ?userID=<?php echo $userID; ?>&name=<?php echo $name; ?> It doesn't make a difference .... it just displays the correct userID and name in the link. Once the INPUT button is clicked it will bring you to this page: <?php $query = "SELECT * FROM users WHERE userID = '".$_POST['selectuser']."' AND username = '".$_POST['username1']."'"; $result = mysql_query($query); if(mysql_num_rows($result)) { $userID = $_POST['selectuser']; while($row = mysql_fetch_assoc($result)){ $name = $row['name']; $userID = $row['userID']; $email = $row['email']; $username = $row['username']; $registered = $row['registered']; $last = $row['last']; ?> <?php echo $brokerID; ?> <table border="0" cellspacing="3" cellpadding="3" width="100%" summary="Client table"> <tr> <td><form action="http://localhost/single-client.php?userID=<?php echo $userID; ?>&name=<?php echo $name; ?>" method="post" style="margin:0px;"> <input type="hidden" name="selectuser" id="selectuser" value="<?php echo $userID; ?>" /><input type="hidden" name="username1" id="username1" value="<?php echo $username; ?>" /><input type="hidden" name="name1" id="name1" value="<?php echo $name; ?>" /><input type="submit" name="submit" value="Income" class="button" /></form></td> <td><form action="http://localhost/single-client.php?userID=<?php echo $userID; ?>&name=<?php echo $name; ?>" method="post" style="margin:0px;"> <input type="hidden" name="selectuser" id="selectuser" value="<?php echo $userID; ?>" /><input type="hidden" name="username1" id="username1" value="<?php echo $username; ?>" /><input type="hidden" name="name1" id="name1" value="<?php echo $name; ?>" /><input type="submit" name="submit" value="Bills" class="button" /></form></td> </tr> </table> <h2>Client Profile - <?php echo $_POST['name1']; ?></h2> <table border="0" cellspacing="3" cellpadding="3" width="100%"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Username</font></th> <th><font face="Arial, Helvetica, sans-serif">Email Address</font></th> <th><font face="Arial, Helvetica, sans-serif">Registered</font></th> <th><font face="Arial, Helvetica, sans-serif">Last</font></th> </tr> <tr> <td><?php echo $name; ?></td> <td><?php echo $username; ?></td> <td><?php echo $email; ?></td> <td><?php echo $registered; ?></td> <td><?php echo $last; ?></td> </tr> </table> <?php } } else { echo "<p>Error</p>"; } ?> This page displays the correct user info. Is there a way to do it differently instead of using FORMS and INPUT buttons? and rather using links? Any help would be greatly appreciated. I have got connection to the the mysql database, how do I get the data from the database to display on the webpage Hi, I want to extract weather for 5 cities from www.wunderground.com/global/SB.html and put the field data such as colombo, temprature, humidity and conditions in to a mysql table so I can display the weather for this 5 cities and automatically set a cronjob to update it everyday. Issue is I am unable to extract the specific data from this page. Please help. thanks Hi guys, I want to create a simple database and use PHP to output the database to certain positions on a HTML page. I am basically trying to recreate this: http://bit.ly/dX4byI I want to have a form where the event info is selected from drop down box such as: Venue and Date then the the rest of the form data (event name, artists, opening times) will go into the right box depending on this. Does anyone have any pointers? Am I even going about this the right way?! i have a register and login page where the users can perform register and login task and their detail gets saved in the database. my requirement is that when the user enters his/her account, they should be redirected to their profile page, where they can view all their profile details. Till now i have been able to make the user login and dislay a part of their profile page, for this purpose the code that i am using is
<code>
<?php I'm trying to create a website, that echo's out a bunch of groups, where each group contains a group of checkboxes, containing A value, and a label for the checkbox, the way it is created right now, is foreach that echo's out a bunch of php arrays, which was easier than the static way before - But still, it's static in some way, or not very user friendly at the moment.. My problem is that I really want to write it in a database when I have the option. Is there anyone that can give some tips how to do? At the moment, my foreach looks like this: Code: [Select] echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">'; /* NEXT WE CREATE OUR FOREACH LOOPS TO ECHO THE HTML FOR LOOKS AND CHECKBOXES */ $totalID=0; // this is a counter we use to build our check box names foreach ($items as $list){ $totalID++; // add one to the checkbox name counter echo "<h2>{$list['title']}</h2>\n"; // and echo out our section header foreach ($list['items'] as $cbox){ // now for each item in the list, call it $cbox // $cbox now holds the item name, and point value echo "<label class='checkbox'><input type='checkbox' name='totals[$totalID][]' value='{$cbox[1]}'> {$cbox[0]}</label>\n"; } } echo "</form>"; And my array is something like this: Code: [Select] $items['computers']['title']='Computer Brand'; $items['computers']['items'][]=array('Apple iMac',1); $items['computers']['items'][]=array('Apple Macbook',.5); $items['phones']['title']='Phone Brand'; $items['phones']['items'][]=array('iPhone',1); $items['phones']['items'][]=array('HTC',1); As said, I can write this, but takes time. I want to get it into a database, that data above, but I'm having problems about echo'ing it out, I really can't see how I should do. My current database looks like this: Thank you! Hello. Racking my brains here, having trouble with this. Running a sports league, trying to get the output of one variable at a different font color OR insert a simple check mark graphic. Either way I am stuck. I am a bit out of practice here. Here is the code. Where is says echo ( Locked) is where I would like to either have locked in a color, say green or red - or insert check mark symbol. Code: [Select] <?php $last = -1; while($team = mssql_fetch_assoc($res)) { if ($last != $team['l_id']) { $last = $team['l_id']; echo "<br><span class=\"dk_greyTxt\" style=\"font-size: 14px\"><strong>$team[night] night, $team[type] $team[size]s $team[division]</strong></span><br><br>"; } echo "<strong>$team[teamname] - ($team[shirtcolor] shirts)</strong><br> RegDate: $team[reg_start]<br>RegDone: $team[reg_done]"; $cpt = mssql_query("SELECT firstname, lastname, shirtsize, feepaid, feememo FROM captain WHERE c_id = $team[captain]",$conn); $c = mssql_fetch_assoc($cpt); if($team["locked"] == 1) { echo " (Locked)"; } else { echo " "; } echo "<br>"; I've already made this work, but I'm wondering if anybody has any different/better ideas. I have an excel spreadsheet that we want to turn into a dynamically created webpage. I used excels export to a webpage, and I used yellowpipe.com to convert the source to php, so I didn't have to hand code the entire table. This works just fine. I'm currently going through the entire page to add the actual database calls. Just wondering if somebody with more experience has ever tried to do something similar? Any pros/cons, different ways to accomplish this are welcome. I am using a photo scrolling css animation technique
I'm not sure as far as CPU usage (on server)/(on client) and bandwith usage if loading one picture at a time to scroll versus having a line up "pre-exist" which even then, I would only have five images at a time but what if that is multiplied by 10000 users
Anyway, the current knowledge I have, I have a css animation property that takes in a photo and animates from 0% to 100% keyframe based on margins to make the scrolling happen
In the HTML section there is a list of photos, I would like there to be one line of code that is like a receiver that takes in or reads in arbitrary photo locations and puts that next to be scrolled without interrupting the main animation sequence which I'm not sure if there would be interruption. Anyway I don't know if that is possible. If someone can point out that this idea is obviously flawed then that would be great.
This isn't my ultimate solution, I have yet to see others, I'm just trying to minimize loading and lag
The other problem I have that is interesting is that I want the scrolling to stop when a person hovers over an image, and then resume... I have gotten this to work but only on one image... this is probably a matter of listing out all the key parts of the problem and seeing the solution but
When I had a list of photos that were scrolling together, I could get the whole animation to stop when hovering over the first photo and then take me somewhere (all the photos have working href's) but the animation would not stop if I hovered over any photos after the first. The animation would keep going
So I tried to animate each picture independently and that was just a cluster ****
Still working on that
If someone could point me in the right direction on the main problem of reading in photos live to work with css animation, that would be great.
Edited by greenace92, 03 December 2014 - 07:41 PM. I am trying to be true to the principle that logic and presentation should be kept separate. However, the only way to generate dynamic content and output is using something like PHP, so there is somewhat of a conflict. I just wrote this Function, and I am curious if it breaks the principle above... /** * Returns Online Status Indicator Markup * * Takes User's Last Activity and determines the User's Online Status. * Returns HTML for appropriate Online Status Indicator. * * @param DateTime $lastActivity MySQL DateTime format (yyyy-mm-dd hh:mm:ss) * @return string */ function getOnlineStatus($lastActivity){ // strtotime() converts DateTime format (yyyy-mm-dd hh:mm:ss) into a Unix Timestamp (seconds). // time() is current time measured in the # of seconds since Unix Epoch (January 1 1970 00:00:00 GMT). $minutesOnline = (time() - strtotime($lastActivity))/60; // Determine Online Status. if ($minutesOnline < 15){ // Member Online $indicator = '<img src="/images/Light_Green_10.png" width="10" alt="Member Online" /><br />'; }else if ($minutesOnline < 30){ // Member Idle $indicator = '<img src="/images/Light_Yellow_10.png" width="10" alt="Member Idle" /><br />'; }else{ // Member Offline $indicator = '<img src="/images/Light_Gray_10.png" width="10" alt="Member Offline" /><br />'; } return $indicator; }//End of getOnlineStatus Thanks, Debbie I have the two files below and want to separate php and html. How do I output forum.html with forum_post.html in it? I want to post as many forum_post.html as mysql_num_rows() says. Code: [Select] forum.html ====== <div> <form method="post"> <textarea name="text"></textarea> <input type="submit" /> </form> </div> <div> [b]???[/b] </div> Code: [Select] forum_post.html ====== <div> <h1>Title</h1> <p>Text</p> </div> I'm trying to display my BLOB images in PHP and I've looked around in Google searches but everyone's examples seem to work for their specific code. My table is called 'identification'. Here's my SQL: Code: [Select] == Table structure for table identification |------ |Field|Type|Null|Default |------ |//**id**//|int(11)|No| |image|blob|No| |image_width|char(220)|No| |image_height|char(220)|No| |image_type|enum('jpeg', 'pjpeg', 'png', 'gif')|No| |stickID|int(11)|Yes|NULL I am trying to make PHP output a file in html and using the following code. Code: [Select] <?php readfile("./1/index.html"); ?> ... but it isn't working. How would I get PHP to output a file as HTML? Hi guys I am new here I have had a search around and can't really find out how to do this. Its quite difficult for me to explain and I am really new to PHP / mySQL - just starting out really. I hope to learn from doing small projects like this and seeing how it gets done. So I have a mySQL DB with two different tables - one is called "notesnew" the other is called "users". I have modified a common tutorial on how to make a "to do list" for what I am doing here. Basically users can login and post messages on this list as them self. Each user's post appears as a list item, showing their username, the time they posted the message and the message content. The message content, time and owner of the message is stored in the "notesnew" table. The list of user's, their passwords and their "avatar/profile" image URL location is stored in the "users" table. Now I am having trouble getting each user's avatar image from being output next to each of their posts. The part that is confusing me is being able to match up the username's post with their content that is display - because I am posting the user's name along with their post, based on the logged in "session name" as their username. So basically, all the content being listed is being displayed from the "notesnew" table. I need to somehow figure out what each user's profile image is based on what is stored against their entry in the "users" table. Here is the code I have so far. It is not working properly - it displays all content etc, but displays the avatar / image of the last user that has registered. Can anyone help me out here with some code that works, or pointers to try follow? I know the $finduserprofile part is incorrect in the way it goes through all user's and finds their profileimg, and that the image displayed next to each post is therefore incorrect (as it displays the last member to have registered's avatar, but its just that I don't know how else to do what I am trying to do. Code: [Select] <?php //Connect to the database $connection = mysql_connect('localhost', 'zzzz' , 'zzzzzzz'); $selection = mysql_select_db('zzzzz', $connection); $username = $_COOKIE['ID_my_site']; //Was the form submitted? if($_POST['submit']){ //Map the content that was sent by the form a variable. Not necessary but it keeps things tidy. $content = $_POST['content']; //Insert the content into database $ins = mysql_query("INSERT INTO `notesnew` (content, owner, dp_time) VALUES ('$content', '$username', NOW())"); //Redirect the user back to the members or index page header("Location:index.php"); } /*Doesn't matter if the form has been posted or not, show the latest posts*/ //Find all the notes in the database and order them in a descending order (latest post first). $find = mysql_query("SELECT * FROM `notesnew` ORDER BY id DESC"); $finduserprofile = mysql_query("SELECT * FROM `users` ORDER BY id DESC"); //Setup the un-ordered list echo '<ul>'; while($row = mysql_fetch_array($finduserprofile)) { $imagelocation = $row['profileimg']; //Continue looping through all of them while($row = mysql_fetch_array($find)) { $owner = $row['owner']; //For each one, echo a list item giving a link to the delete page with it's id. echo '<li>' . '<img src ="' . $imagelocation . '">' . $row['owner'] . ' said at ' . $row['dp_time'] . ': ' . $row['content'] . ' <a id="' . $row['id'] . '" href="delete.php?id=' . $row['id'] . '"><img src="delete.png" alt="Delete?" /></a></li>'; } } //End the un-ordered list echo '</ul>'; ?> Hello! Im new here and want to start my new php carreer Well, I'm already working quite hard, but now I don't know what to do I've got it so far: <?php echo html::chars($message->text); ?> Is there any way I could modify the output, so it just displays the first 20 characters or so? Thank you all very much! I have noticed that today that some of the content that is saved from my form is printing random characters and crap. I am using htmlentities on the form input and it seems to be adding more rubbish. I am using the UTF-8 charset as a meta tag. Is this the correct way of using htmlentities? htmlentities($string, ENT_QUOTES, 'UTF-8') Also i noticed the other day with a problem I had that using htmlentities was replacing " with &" when i thought it should have just been " I found this site: http://www.wallpaperama.com/forums/how-to-save-html-output-code-from-php-script-t6898.html it demonstrates how to save html output code from php script. here is an example: http://ads4agents.com/date.php I cant get it to work on my site...where is the correct place ad these: ob_start(); $HtmlCode= ob_get_contents(); ob_end_flush(); How can I get this to work in my php? view_ad.php <html> <body> <center> <br/> <h1>Apartment Reference #: <?php echo $_POST["reference"]; ?><br /></h1> <br/> <?php echo $_POST["application"]; ?>, <?php echo $_POST["deposit"]; ?><br /> <?php echo $_POST["pets"]; ?><br /> <br/> <?php echo $_POST["community"]; ?><br /> <?php echo $_POST["interior"]; ?><br /> <?php echo $_POST["amenities"]; ?><br /> <br/> <?php echo $_POST["contact"]; ?><br /> <a href="<?php echo $_POST['website'] ?>"><?php echo $_POST['website'];?></a><br/> <br/> <br/> <br/> </body> </html> |