DarkPrince2005 Posted September 21, 2007 Share Posted September 21, 2007 Attached is the code for a page that is suppose to fetch all the data from a table and taking some of the information and calculating age in days. It works in xampp on my pc, but when i upload it to a internet server it only displays a blank page. code]<? mysql_connect("localhost","root",""); mysql_select_db("npa"); // Begin your table outside of the array echo "<html><head><title></title><link rel='stylesheet' href='stylesheet.css' type='text/css'> <style> a:link{font-family:'Times New Roman'; font-size:10pt; color:'#ffffff'; font-weight:700; text-decoration:none; } a:visited{font-family:'Times New Roman'; font-size:10pt; color:'#ffffff'; font-weight:700; text-decoration:None; } a:hover{font-family:'Times New Roman'; font-size:10pt; text-decoration:none; color:'#B37A04'; font-weight:700; } a:active{font-family:'Times New Roman'; font-size:10pt; color:'#ffffff'; font-weight:700; } </style></head><body bgcolor='#FDCC67' topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0'> <center><table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'> <tr><td valign='top' width='140' bgcolor='#000000'><br> <a href='home.html'>Home</a><br><br> <a href='view.php'>View Records</a><br><br> <a href='add.html'>Add Record</a><br><br> <a href='edit1.php'>Edit Record</a><br><br> <a href='delete1.php'>Delete Record</a><br><br> <a href='report.php'>View Report</a><br><br> <a href='q.php'>Query Report</a><br><br> <a href='search1.php'>Search</a></td><td valign='top' align='center'><table><tr> <td align='right' valign='top'></td></tr> <tr><td align='center' valign='top'><h1>Disciplinaries: Age Analysis</h1></td></tr> <tr><td align='center' valign='top'></td></tr> <tr><td valign='top'><br><form action='disciplinaryageview.php' method='post'><table cellpadding='2' border='0' cellspacing='0'> <tr bgcolor='#ff9900' height='50'> <td> </td><td> </td> <td><b>File_Ref</b></td> <td> </td><td> </td> <td><b>First Name</b></td> <td> </td><td> </td> <td><b>Last Name</b></td> <td> </td><td> </td> <td><b>Persal Number</b></td> <td> </td><td> </td> <td><b>Occupation</b></td> <td> </td><td> </td> <td><b>Unit</b></td> <td> </td><td> </td> <td><u><b>Region</b></td> <td> </td><td> </td> <td><u><b>Age ( Days )</b></td> <td> </td><td> </td> <td> </td><td> </td></tr>"; // Define your colors for the alternating rows $color1 = "#FFBB55"; $color2 = "#CCEEFF"; $row_count = 0; // Perform an statndard SQL query: $date1= mysql_query("SELECT datediff(curdate(),Date_Recieved) from dis;"); $r = mysql_query ("UPDATE dis SET Date_Added=(SELECT datediff(curdate(),Date_Recieved));"); $q = mysql_query("SELECT * from dis order by Date_Added desc"); // We are going to use the "$row" method for this query. This is just my preference. while ($row = mysql_fetch_array($q)) { $file_ref=$row["File_Ref"]; $ef=$row["Employee_Firstname"]; $el=$row["Employee_Lastname"]; $persal=$row["Persal_Number"]; $occ=$row["Occupation"]; $unit=$row["Unit"]; $region=$row["Region"]; $date_added=$row["Date_Added"]; /* Now we do this small line which is basically going to tell PHP to alternate the colors between the two colors we defined above. */ $row_color = ($row_count % 2) ? $color1 : $color2; // Echo your table row and table data that you want to be looped over and over here. echo " <tr> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color' height='40'><input type='hidden' name='duh' value='$row[File_Ref]'>$row[File_Ref]</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$ef</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$el</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$persal</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$occ</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$unit</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$region</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td align='left' bgcolor='$row_color'>$date_added</td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'> </td> <td bgcolor='$row_color'><input type='submit' value=' View '></td> <td bgcolor='$row_color'> </td></tr>"; // Add 1 to the row count $row_count++; } // Close out your table. echo "</table></form>"; ?>[ Quote Link to comment https://forums.phpfreaks.com/topic/70118-solved-display-issue/ Share on other sites More sharing options...
GingerRobot Posted September 21, 2007 Share Posted September 21, 2007 It'll be to do with differences in the php settings between your local and live servers. The first thing i'd try is using full opening tags (<?php) rather than short ones(<?), since this is an option in php. I also suggest you add these two lines at the top: <?php ini_set('display_errors','On'); error_reporting(E_ALL); ?> This will mean that any errors will get displayed, even if your live server isn't set up to display them. Quote Link to comment https://forums.phpfreaks.com/topic/70118-solved-display-issue/#findComment-352165 Share on other sites More sharing options...
DarkPrince2005 Posted September 21, 2007 Author Share Posted September 21, 2007 Thanx it now works but, on that page it has a button to forward to a next page and display all the information of that specific row, the only problem is that its not working. It doesnt matter what button you click in the list it displays the first record in the table. <?php ini_set('display_errors','On'); error_reporting(E_ALL); mysql_connect("localhost","root",""); mysql_select_db("npa"); $q = mysql_query("SELECT * from dis where File_Ref like '$_POST[duh]'"); while ($row = mysql_fetch_assoc($q)) { $ef=$row["Employee_Firstname"]; $el=$row["Employee_Lastname"]; $persal=$row["Persal_Number"]; $occ=$row["Occupation"]; $level=$row["Level"]; $gender=$row["Gender"]; $race=$row["Race"]; $unit=$row["Unit"]; $region=$row["Region"]; $date_added=$row["Date_Added"]; echo "<html><head><title></title><link rel='stylesheet' href='stylesheet.css' type='text/css'> <style> a:link{font-family:'Times New Roman'; font-size:10pt; color:'#ffffff'; font-weight:700; text-decoration:none; } a:visited{font-family:'Times New Roman'; font-size:10pt; color:'#ffffff'; font-weight:700; text-decoration:None; } a:hover{font-family:'Times New Roman'; font-size:10pt; text-decoration:none; color:'#B37A04'; font-weight:700; } a:active{font-family:'Times New Roman'; font-size:10pt; color:'#ffffff'; font-weight:700; } </style></head><body bgcolor='#FDCC67' topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0'> <center><table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'> <tr><td valign='top' width='140' bgcolor='#000000'><br> <a href='home.html'>Home</a><br><br> <a href='view.php'>View Records</a><br><br> <a href='add.html'>Add Record</a><br><br> <a href='edit1.php'>Edit Record</a><br><br> <a href='delete1.php'>Delete Record</a><br><br> <a href='report.php'>View Report</a><br><br> <a href='q.php'>Query Report</a><br><br> <a href='search1.php'>Search</a></td><td valign='top' align='center'><table><tr> <td align='right' valign='top'><form action='search2.php' method='post'><b>Search by Persal Number:</b> <input type='text' name='search'> <input type='submit' value='Search'></form></td></tr> <tr><td align='center' valign='top'><h1>View Disciplinary Records</h1></td></tr> <tr><td align='center' valign='top'></td></tr> <tr><td align='center' valign='top'><br><center> <table cellpadding='0' border='0' cellspacing='0'><tr> <td valign='top'><table width='400'> <tr><td><b>File Ref</td><td> </td> <td>$ef</td></tr> <tr><td><b>Employee Firstname</td><td> </td> <td>$el</td></tr> <tr><td><b>Employee Lastname</td><td> </td> <td>$row[Employee_Lastname]</td></tr> <tr><td><b>Persal Number</td><td> </td> <td>$row[Persal_Number]</td></tr> <tr><td><b>Occupation</td><td> </td> <td>$row[Occupation]</td</tr> <tr><td><b>Level</td><td> </td> <td>$row[Level]</td</tr> <tr><td><b>Gender</td><td> </td> <td>$row[Gender]</td</tr> <tr><td><b>Race</td><td> </td> <td>$row[Race]</td</tr> <tr><td><b>Suspension</td><td> </td> <td>$row[suspensions]</td</tr> <tr><td><b>Period</td><td> </td> <td>$row[Period]</td></tr> <tr><td><b>Date Recieved</td><td> </td> <td>$row[Date_Recieved]</td</tr> <tr><td><b>Unit</td><td> </td> <td>$row[unit]</td</tr> <tr><td><b>Region</td><td> </td> <td>$row[Region]</td</tr> <tr><td><b>Date Of DC</td><td> </td> <td>$row[Date_Of_DC]</td</tr> <tr><td><b>Status</td><td> </td> <td>$row[status]</td</tr> <tr><td><b>Category</td><td> </td> <td>$row[Category]</td></tr> <tr><td><b>Outcome</td><td> </td> <td>$row[Outcome]</td></tr></table></td><td> </td><td valign='top'><table width='400'> <tr><td valign='top'><b>Status Report</td><td> </td> <td width='250'>$row[status_Report]</td></tr> <tr><td valign='top'></td><td> </td> <td></td></tr> <tr><td valign='top'><b>Age</td><td> </td> <td>$row[Date_Added] Days</td></tr> </table></table></td></tr></table></td></tr></table> </body>"; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/70118-solved-display-issue/#findComment-352168 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.