PHP - Php / Mysql Data Listing
hello guys,
I'm stuck he I have a table called customer_messages which has a entryid, custid, fromname, message, flag i have written a script to enter data into this. and another script to count the number of entries in the table. now i want to display entries in the table on to a script what i did was this: flag is by default '0' which mean unread. insertion code: Code: [Select] insert into customer_messages (customer_id,customer_fname,customer_message,flag) values('21','mike','hello!','0') fetching number of unread messages Code: [Select] select count(*) from customer_messages where flag = '0' $q = "select count(*) from customer_messages where flag = '0'"; $w = mysql_query($q); $r = mysql_fetch_array($w); $t = $r[0]; $t now gives me total number of unread messages in the db. now, I want to display these messages on to a page in the following format: ----------------------------------------------------------------------------------------------- | sender | message | mark as read | ----------------------------------------------------------------------------------------------- | name_from_db | message_from_db | check box | ----------------------------------------------------------------------------------------------- | name_from_db | message_from_db | check box | ----------------------------------------------------------------------------------------------- how do I do this? I'm assuming that I have to use a loop here, I put the code in a while loop, but that didnt work out for me. can I use a for loop here? if yes how do i use it? my brain's froze now so, i cant think atm, can someone help me out please? ================================================================================= in short i need the data from database to be listed as listbox control in asp.. is it possible? Similar TutorialsHi there im not quite sure how to do something and was wondering if anyone can help me, I am going to create a large database with lots of fields and these are going to be displayed on a page i want to limit it to 20 per page and be able to sort them aswell by ID (default) and then a-z or z-a, i dont know how to do this and i also need to know how to create the next previous and last and first links im guessing theres a count++ involved ? im not quite sure but anyway if someone can help it will be great. Thanks, Blink359 I'm having trouble listing the most recent 10 content. How can I solve this problem. $sorgu = mysqli_query("select * from icerik order by id desc limit 0,10");
while($goster=mysqli_fetch_assoc($sorgu)) { } error code: Fatal error: Uncaught ArgumentCountError: mysqli_query() expects at least 2 arguments, 1 given in C:\xampp\htdocs\blog\orta.php:3 Stack trace: #0 C:\xampp\htdocs\blog\orta.php(3): mysqli_query('select * from i...') #1 C:\xampp\htdocs\blog\index.php(4): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\blog\orta.php on line 3 Right, it's hard to explain, but I'll try my best. Litterally, I have a 'tab' box on my homepage. And a table called 'news'. Now, the table has the rows "shorttitle" "shortstory" and "image" in it. I want the title the three latest titles to be on the three tabs, and the story and image in the respective content areas. (The table auto increments the ID, and so order by ID descending limit of 3 yes?) Now, the code for the tabs is: Code: [Select] <?php $query = "SELECT * FROM news where published = '1' ORDER by id DESC LIMIT 3"; $row_news = mysql_fetch_array($query); ?> <div id="myTabs"> <ul> <li><a href="#firsttab"></a><? echo $row_news['shorttitle']; ?></li> <li><a href="#secondtab">newsID2</a></li> <li id="last"><a href="#thirdtab">newsID3 </a></li> </ul> <div id="firsttab" class="tab_content"> <div class="rafat"> <img src="<? echo $row_news['image']; ?>" /> <p> <? echo $row_news['shortstory']; ?> </p> </div> </div> <div id="secondtab" class="tab_content"> <div class="rafat"> <img src="newsIMAGE2" /> <p> newsSTORY2 </p> </div> </div> <div id="thirdtab" class="tab_content"> <div class="rafat"> <img src="newsIMAGE3" /> <p> newsSTORY3 </p> </div> </div> </div> Now, i've filled in the first tab with the MYSQL queries, but i'm unsure how to fill in the other two, because of the way it's coded.. I can't do a 'repeating' code, because of the IDs of the divs, and the three tabs are bunched together.. Anyone any ideas? Much apreciated. Thanks Luke Hi I have used TCPDF to generate documents with single values from a mysql table. Now I want to generate a calendar. I have a table events_pbw which contains (amongst others) the fields id, date and name. I would like to generate a pdf which lists all of the results for entries after a particular date (eg Jan 1st) I have this: // get data from events_pbw table $result = mysql_query("SELECT id, date, name FROM events_pbw WHERE `date` > 2011-01-01" "); while($row = mysql_fetch_array($result)) { $appid = $row['id']; $date = $row['date']; $name = $row['name']; } But I don't know how to get the full list of results into the pdf. I'm sure this is very easy but I'm not great on php coding! Does anyone have any examples or help they could give me? Many thanks Hi all, I have a MySQL table with the field 'number'. When I SELECT * from that field, I get a return for the rows of 'number' in the order 1, 2, 3, 4, etc... SELECT * FROM products;Is there a way where I can get a return in the reverse order, so highest to lowest (4, 3, 2, 1, etc...)? Edited by Phaelon, 13 May 2014 - 03:23 AM. Hi, I have a little problem that I can't seem to solve myself. My coding skills are very limited, just wanted to mention that . I have a list of rows, bascially banners that members submit. They have to be manually approved by me before they are put on air. So to quicken up this process I made this little code in my admin panel. $bq = mysql_query("SELECT id, usrid, bname, burl, btarget FROM ban_rotator WHERE status = 'Waiting'"); $pb = mysql_num_rows($bq); if ($_GET['ap']) { $bid = $_GET['ap']; mysql_query("UPDATE ban_rotator SET status = 'Active' WHERE id = '$bid'"); It works perfectly except for one thing. It will always show the banner I just approved in addition to the remaining ones that are waiting. Any tips would be appreciated. I have to add that this code is a part of a fairly large admin panel php file. Just realized i need a bit more explanation. If I hit refresh in the browser the one I just approved will be gone. As I would like it to be after hitting Approve on the banner in question. If I just approve the second banner (after approving the first), the first will be gone from the list of waiting and the second will still show until I either hit approve on the third or hit refresh in the brower. Alka Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. This could be PHP or MySql so putting it in PHP forum for now... I have code below (last code listed) which processes a dynamically created Form which could have anywhere from 0 to 6 fields. So I clean all fields whether they were posted or not and then I update the mySQL table. The problem with this code below is that if, say, $cextra was not posted (i.e. it wasnt on the dynamically created form), then this code would enter a blank into the table for $cextra (i.e. if there was already a value in the table for $cextra, it gets overwritten, which is bad). What is the best way to handle this? I'm thinking i have to break my SQL query into a bunch of if/else statements like this... Code: [Select] $sql = "UPDATE cluesanswers SET "; if (isset($_POST['ctext'])){ echo "ctext='$ctext',"; } else { //do nothing } and so on 5 more times.... That seems horribly hackish/inefficient. Is there a better way? Code: [Select] if (isset($_POST['hidden']) && $_POST['hidden'] == "edit") { $cimage=trim(mysql_prep($_POST['cimage'])); $ctext=trim(mysql_prep($_POST['ctext'])); $cextra=trim(mysql_prep($_POST['cextra'])); $atext=trim(mysql_prep($_POST['atext'])); $aextra=trim(mysql_prep($_POST['aextra'])); $aimage=trim(mysql_prep($_POST['aimage'])); //update the answer edits $sql = "UPDATE cluesanswers SET ctext='$ctext', cextra='$cextra', cimage='$cimage', atext='$atext', aextra='$aextra', aimage='$aimage'"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { } Hi I am trying to select and order data/numbers from a colum in a mysql data base however i run the code and it returns no value just a blank page no errors or any thing so i think the code is working right but then it returns no result? Please help thanks Here is the code: <?php $host= "XXXXXX"; $mysql_user = "XXXXXX"; $mysql_password = "XXXXXX"; $mysql_database = "XXXXXXX"; $connection = mysql_connect("$host","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server."); mysql_select_db($mysql_database) or die ("Unable to select requested database."); $row = mysql_fetch_assoc( mysql_query( "SELECT XP FROM Game ORDER BY number DESC LIMIT 1" ) ); $number = mysql_result(mysql_query("SELECT XP FROM Game ORDER BY number DESC LIMIT 1"), 0); echo "The the highest XP is $number"; ?> hi guys, im new to this forum I'm new also to php, I need help from you guys: I want to display personal information from a certain person (the data is on the mysql database) using his name as a link: example: (index.php) names 1. Bill Gates 2. Mr. nice Guy i want to click Bill Gates (output.php) Name: Bill Gates Country:xxxx Age: xx etc. How can i make this or how to learn this? I have a form on our website that a user can fill out for custom product. I want the form data to be 1) stored into a mysql database AND after storing said data, 2) email the same data to our sales department. 1) The form data DOES get stored into mysql database (except for the first two fields, for some weird reason) 2) I added a "mail" section to the php file that stores the data into the database, but it is not working correctly. I have stripped the email portion down to sending just one of the fields in the "message" to make it easier for troubleshooting I have included here, both the form section of the html file, and the formdata.php file that processes the data for your analysis. I am relatively new to php so there are going to be some issues with security, but I can work on those after I get the store & email process to work correctly. Please review my code and see if anyone can be of assistance. I looked through the forums and couldn't find another issue that was the same as mine. If I just overlooked, please tell me the thread post #. Thanks THE FORM WHICH COLLECTS THE DATA ******************************* <form method=POST action=formdata.php> <table width="640" border=0 align="center"> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=FName size=25></td> <td><div align="right"><b>Telephone</b></div></td> <td><input type=text name=Tel size=25></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=LName size=25></td> <td><div align="right"><b>Fax</b></div></td> <td><input type=text name=Fax size=25></td> </tr> <tr> <td align=right><b>Title</b></td> <td><input type=text name=Title size=25></td> <td><div align="right"><b>Email</b></div></td> <td><input type=text name=Email size=50></td> </tr> <tr> <td align=right><b>Company</b></td> <td><input type=text name=Comp size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Address</b></td> <td><input type=text name=Addr size=25></td> <td><div align="right"><b>Estimated Annual Volume</b></div></td> <td><input type=text name=EAV size=25></td> </tr> <tr> <td align=right><b>City</b></td> <td><input type=text name=City size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>State/Province</b></td> <td><input type=text name=SProv size=25></td> <td><div align="right"><b>Application</b></div></td> <td><input type=text name=Appl size=25></td> </tr> <tr> <td align=right><b>Country</b></td> <td><input type=text name=Ctry size=25></td> <td><div align="right"><b>Type of System</b></div></td> <td><input type=text name=Syst size=25></td> </tr> <tr> <td align=right><b>Zip/Postal Code</b></td> <td><input type=text name=ZPC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td><div align="right"><strong><font color="#FFFF00" face="Arial, Helvetica, sans-serif">COIL DESIGN</font></strong></div></td> <td><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PARAMETERS</strong></font></td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Primary Resistance (ohms)</b></td> <td><input type=text name=Pres size=25></td> <td><div align="right"><b>Primary Inductance (mH)</b></div></td> <td><input type=text name=Pind size=25></td> </tr> <tr> <td align=right><b>Secondary Resistance (ohms)</b></td> <td><input type=text name=Sres size=25></td> <td><div align="right"><b>Secondary Inductance (H)</b></div></td> <td><input type=text name=Sind size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Peak Operating Current (Amps)</b></td> <td><input type=text name=POC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Output Energy (mJ)</b></td> <td><input type=text name=Egy size=25></td> <td><div align="right"><b>Output Voltage (kV)</b></div></td> <td><input type=text name=Volt size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b># HV Towers per Coil</b></td> <td><input type=text name=TPC size=25></td> <td><div align="right"><b># of Coils per Package</b></div></td> <td><input type=text name=CPP size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <th colspan=4><b>Please enter any additional information he </b></th> </tr> <tr> <th colspan=4><textarea name=Mess cols=50 rows=10 id="Message"></textarea></th> </tr> </table> </dl> <div align="center"> <p> <input type=hidden name=BodyTag value="<body bgcolor="#484589" text="#FFFFFF" link="#FFFF00" alink="#FFFFFF" vlink="#FF7F00">"> <input type=hidden name=FA value=SendMail> </p> <p><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PLEASE MAKE SURE ALL INFORMATION<br> IS CORRECT BEFORE SUBMITTING</strong></font></p> <p> <input type=submit value="Submit Form"> </p> </div> </form> THE FILE THAT PROCESSES THE FORM DATA (formdata.php) *********************************************** <?php $con = mysql_connect("localhost","XXX","XXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customform", $con); $sql="INSERT INTO formdata (Fname, Lname, Title, Comp, Addr, City, SProv, Ctry, ZPC, Tel, Fax, Email, EAV, Appl, Syst, Pres, Pind, Sres, Sind, POC, Egy, Volt, TPC, CPP, Mess) VALUES ('$_POST[Fname]','$_POST[Lname]','$_POST[Title]','$_POST[Comp]','$_POST[Addr]','$_POST[City]','$_POST[SProv]','$_POST[Ctry]','$_POST[ZPC]','$_POST[Tel]','$_POST[Fax]','$_POST[Email]','$_POST[EAV]','$_POST[Appl]','$_POST[Syst]','$_POST[Pres]','$_POST[Pind]','$_POST[Sres]','$_POST[Sind]','$_POST[POC]','$_POST[Egy]','$_POST[Volt]','$_POST[TPC]','$_POST[CPP]','$_POST[Mess]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Your Information Was Successfully Posted"; mysql_close($con); $to = "recipient email address here"; $subject = "Custom Form"; $email = $_POST['Email'] ; $message = $_POST['Comp'] ; $headers = "From: $Email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> Good day: Is there a way to create a proxy or coding in php that it is constantly getting the data from a sql database and inserting it into a mysql database? Any help will be appreciated. Hi all, I want to create a website, where the user can add any number of custom fields, and then put any info there he or she wants. I then need a site to display the info. The problem is that I have no idea on what would be the smartest way to do this. Let's say it was about flowers and they created a "type" field and a "stock" field. How could i make sure, that the correct stock will be displayed with the correct type field? Code: [Select] id: 20 Reason: this is a test id: 21 Reason: Tests id: 22 Reason: Lolcatz id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: Reason: id: 36 Reason: Test As you can see on the 2nd code box there are id's 20,21,22 and 36 in the database the rest are not active in the database. i am using using Code: [Select] for to pull out the id that starts with the lowest value in the database, and only have it run until it gets to the maximum value. Code: [Select] for ($id=$set_min; $set_max<=7; $id++) { // $id=$set_min is pulling the smallest value and $set_max is pulling the maximum value so it stops after it gets to 36 $query=mysql_query("SELECT * FROM posted WHERE id = $id"); $query_row=mysql_fetch_array($query); $reason = $query_row[reason]; $pulled_id = $query_row[id]; $pulled_pic22 = $query_row[picture]; $href_pull = "<a href=" . "search.php?id=" . "$id" .">"; echo "<td>" . $href_pull . "<img src=$pulled_pic22 height=200 width=150 />" . "</td>"; } how would i make it so i do not pull the values 23-35 which are not in the active database. Example: http://dev.hackmuch.com/of-the-day/search.php?id=36 Hi guys, I'm recent working on my php to add the row in mysql database. I need a bit of your help as I would like to know how to check the data in mysql database if it have added in mysql and then print it out without adding another same row? here's the current code: Code: [Select] <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $pass = clean($_GET['pass']); $login = clean($_GET['login']); $all = clean($_GET['all']); if($username == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Username and password are missing. You must enter both or the other one.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'username = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if(isset($_GET['login'])) { $insert[] = 'LoggedUser = \'' . clean($_GET['login']) . '\''; } if(isset($_GET['all'])) { $insert[] = 'all = \'' . clean($_GET['all']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if($username) { $qrytable1="SELECT username, LoggedUser FROM Online_Users WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "<p id='LoggedUser'>"; echo $row['LoggedUser'] . "</p>"; } } if($username && $login == '1') { $sql="INSERT INTO Online_Users (username, LoggedUser) VALUES ('$_GET[user]','$_GET[login]')"; $result = mysql_query($sql); if($result) { $qrytable1="SELECT username, LoggedUser FROM Online_Users WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "<p id='LoggedUser'>"; echo $row['LoggedUser'] . "</p>"; } } } elseif($username == 'all') { $names = implode(',',$insert); $result = mysql_query("SELECT * FROM Online_Users") or die('Error: ' . mysql_error()); $num_rows = mysql_num_rows($result); echo "There are $num_rows Users Online right now"; } } } ?> How to sort data from table? Currently its sorted by ID. But I want to add option that admin can sort data (click on up/down link or whatever). Its about forum script and all forums have categories. Forum and categories are in same table. Forum "parent" is ID of category. So i have following sorting: Cat1 [ID1] ->Forum1 [ID2] [PARENT1] ->Forum2 [ID3] [PARENT1] Cat2 [ID4] ->Forum3 [ID5] [PARENT2] ->Forum4 [ID6] [PARENT2] I need to add additional field "sort". On click admin can UPDATE sorting by increasing/decreasing number. But problem is categories and forum are in same table. If I want to move up FORUM1 (ID2) with (for example) "sort" number 2 I must decrease number (-1) and that forum will be with same sort number as category above. Also if I want to move Category up/down it also must move all forums from that category (but that is not big problem). What is best way to solve this? hello, I need xml file as playlist.xml and i want to retrive data from my mysql table. I have the following code as i am trying to use php code inside playlist.xml file. Code: [Select] <?xml version="1.0" encoding="utf-8"?> <xml> <?php $dbhost='localhost'; $dbuser='pavel'; $dbpass='pavel123'; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db("amarmusic"); $sql=("select *from bband where artist='Meghdol' and album='Drohe Montre Valobasha';"); $res = mysql_query($sql); while ($result = mysql_fetch_array($res)){ ?> <track> <path> <? $result['link']?></path> <title><? $result['title']?></title> </track> <? } ?> </xml> but unfortunately its not working. any1 have any idea how to fix it? please help me. I have a script that is supposed to allow a user to add their details to a members table in the database. It acts as if the user has been added to the database by stating the thank you message, but there is no entry into the database. I can connect to the database and have another script running OK that allows me to view all of the information in the members table with a loop (this data was entered using php my admin's GUI). Here is the script that is supposed to add the member. Any help would be greatly appreciated. <?php error_reporting(-1); $user_name = "root"; $password = ""; $database = "test"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO members (fname, sname, email, password, gender) VALUES ('$_POST[fname]','$_POST[sname]','$_POST[email]','$_POST[password]','$_POST[gender]')"; $result = mysql_query($SQL); mysql_close($db_handle); print "Thanks for joining us ".$_POST['fname']."."; } else { print "Database NOT Found"; mysql_close($db_handle); } ?> I'm not sure what I'm doing wrong here... This is my index <html <head> <title>Admin applications</title> </head> <body text="#000000"> <center> <?php include("connect.php"); echo "<table cellpadding='3' cellspacing='2' summary='' border='3'>"; echo "<tr><td>Real name:<br><br>"; echo $row['real_name']; echo "</td><td>Age:<br><br>"; echo $row['age']; echo "</td><td>In-Game Name:<br><br>"; echo $row['game_name']; echo "</td><td>Steam ID:<br><br>"; echo $row['steamid']; echo "</td><td>Agreement:<br><br>"; echo $row['agreement']; echo "</td><td>Will use vent:<br><br>"; echo $row['vent']; echo "</td><td>Activity:<br><br>"; echo $row['activity']; echo "</td><td>Why this person wants to be an admin:<br><br>"; echo $row['why']; echo "</td></tr></table>"; ?> </center> </body> </html> and this is my database connect <?php $database="admin"; mysql_connect ("localhost", "root", "waygan914"); @mysql_select_db($database) or die( "Unable to select database"); mysql_query("SELECT * FROM applications"); ?> The database table "applications" has 8 fields, and 2 records, but when I view the page i get the table but no data: Hi guys, I have a little problem here. I have stored the data in firstname column of mysql database. I am trying to achieve by print the data from the mysql and input the data on my php page, but the page is blank. Here it is the code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydatabasename'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $login = clean($_GET['user']); $password = clean($_GET['pass']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PASSWORD ID missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qry="SELECT * FROM members WHERE login='$login' AND passwd='$password'"; $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_row($result); $firstname = htmlspecialchars($author['firstname']); echo("$firstname <br>"); } else { echo 'Username and/or Password not found.'; } } ?> Do you know why the php page is blank as I effort to get the data from mysql?? Any idea?? |