RidgeandGable Posted September 4, 2014 Share Posted September 4, 2014 hey guys Doing last bit of site now and after doing full testing I found 1 little bug that I don't like I created an appointment section with a table to display resuilts from mysql, works great, but add more than 1 appiontment and its almost adding a whole new pageSee attachment for picHeres the code for the table <?php echo '<h2>Customer Appointments</h2>'; ?> </span></div><table width="1248" border="3" align="center"> <tr class="new"> <td width="116" class="re" style="text-align: center"><strong>Date Booked</strong></td> <td width="96" class="re" style="text-align: center"><strong class="table">Time Booked</strong></td> <td width="823" class="re" style="text-align: center"><strong class="table">Notes</strong></td> </tr> <?php do { ?> <tr class="table"> <td class="re" style="text-align: center; color: #FFF;"><?php echo $row['datebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['timebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['notes']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($Recordset1)); ?> </table> <span class="re"> <?php Is there anyway I can make the Titles: Date Booked, Time Booked, Notes and have all results showing directly underneath? Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 its almost adding a whole new page Wow....it' weird....it's not from the code above I think, that script looks good for me. Disable css and try again. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted September 4, 2014 Share Posted September 4, 2014 Is there anyway I can make the Titles: Date Booked, Time Booked, Notes and have all results showing directly underneath? The code you posted should be doing just that. However from the screenshot you posted it appears the code you have posted is within another while loop (or in your wording a repeat region) which is why the headings are being duplicated. Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Here is the entire page code: <?php require_once('/Connections/new.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = $_SESSION['MM_Username']; } mysql_select_db($database_new, $new); $query_Recordset1 = sprintf("SELECT * FROM appointments WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $new) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); session_START() ?> <?PHP // get the files belonging to the logged in user $result = mysql_query('SELECT id, username, datebooked, timebooked, notes FROM appointments WHERE username=\''.mysql_real_escape_string($_SESSION['MM_Username']).'\''); // check query did execute without errors if($result) { // output each file while($row = mysql_fetch_assoc($result)) { ?> <title>Appointments</title> <style type="text/css"> body p { text-align: center; } body { background-image: url(slate.jpg); } .new { color: #FFF; } .new { font-weight: bold; } .new .new { text-align: left; } .new { color: #FFF; } .re { text-align: center; } .table .re { color: #FFF; } .table .re { color: #FFF; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" align="center"/> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> </p> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" align="center"/> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> </p> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a class="MenuBarItemSubmenu" href="success.php">Home</a> <li><a href="#">Gallery</a></li> <li><a class="MenuBarItemSubmenu" href="appointments.php">Visits</a> <li><a class="MenuBarItemSubmenu" href="#">Contact</a> </ul> <p align="center"><br> <br> </p> <p align="center"><img src="/images.jpg" width="323" height="156"><br /> <p align="center"> </p> <div align="center"> <span class="new"> <?php echo '<h2>Customer Appointments</h2>'; ?> </span></div><table width="1248" border="3" align="center"> <tr class="new"> <td width="116" class="re" style="text-align: center"><strong>Date Booked</strong></td> <td width="96" class="re" style="text-align: center"><strong class="table">Time Booked</strong></td> <td width="823" class="re" style="text-align: center"><strong class="table">Notes</strong></td> </tr> <?php do { ?> <tr class="table"> <td class="re" style="text-align: center; color: #FFF;"><?php echo $row['datebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['timebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['notes']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($Recordset1)); ?> </table> <span class="re"> <?php } // query did not execute, log or show error message } else { trigger_error('Cannot get users files from database: ' . mysql_error()); } mysql_free_result($Recordset1); ?> </span> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 This code should be immediately restructure from scratch You don't have to repeat your css and javascrip code adding them into while loops. Why are you using two identical queries: SELECT * FROM appointments WHERE username = %s" //and SELECT id, username, datebooked, timebooked, notes FROM appointments WHERE username= Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Hmm, Css and javasript was added by dreamweaver to add the menubar I think and I'm not sure why 2 queries are in there, I'll look at that l8r as its time to pick kids up from schoolDon't say to rebuild it lol, its nearly 99% working apart from this Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 (edited) I am at work now to get my time looking more deeply into this beautiful script, but you should die here thought $query_Recordset1 = sprintf("SELECT * FROM appointments WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $new) or die(mysql_error()); What is $new? your database credentials? Edited September 4, 2014 by jazzman1 Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 I removed a large section of code and refreshed and its looking a little more proper, but have a few errors New code <?php require_once('/Connections/new.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = $_SESSION['MM_Username']; } mysql_select_db($database_new, $new); $query_Recordset1 = sprintf("SELECT * FROM appointments WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $new) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); session_START() ?> <?PHP // get the files belonging to the logged in user $result = mysql_query('SELECT id, username, datebooked, timebooked, notes FROM appointments WHERE username=\''.mysql_real_escape_string($_SESSION['MM_Username']).'\''); // check query did execute without errors if($result) { // output each file while($row = mysql_fetch_assoc($result)) { ?> <title>Appointments</title> <style type="text/css"> body p { text-align: center; } body { background-image: url(slate.jpg); } .new { color: #FFF; } .new { font-weight: bold; } .new .new { text-align: left; } .new { color: #FFF; } .re { text-align: center; } .table .re { color: #FFF; } .table .re { color: #FFF; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" align="center"/> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> </p> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" align="center"/> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> </p> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a class="MenuBarItemSubmenu" href="success.php">Home</a> <li><a href="#">Gallery</a></li> <li><a class="MenuBarItemSubmenu" href="appointments.php">Visits</a> <li><a class="MenuBarItemSubmenu" href="#">Contact</a> </ul> <p align="center"><br> <br> </p> <p align="center"><img src="/images.jpg" width="323" height="156"><br /> <p align="center"> </p> <div align="center"> <span class="new"> <?php echo '<h2>Customer Appointments</h2>'; ?> </span></div><table width="1248" border="3" align="center"> <tr class="new"> <td width="116" class="re" style="text-align: center"><strong>Date Booked</strong></td> <td width="96" class="re" style="text-align: center"><strong class="table">Time Booked</strong></td> <td width="823" class="re" style="text-align: center"><strong class="table">Notes</strong></td> </tr> <?php do { ?> <tr class="table"> <td class="re" style="text-align: center; color: #FFF;"><?php echo $row['datebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['timebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['notes']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($Recordset1)); ?> </table> <span class="re"> <?php } // query did not execute, log or show error message } else { trigger_error('Cannot get users files from database: ' . mysql_error()); } mysql_free_result($Recordset1); ?> </span> Now I can see the table is bigger but i have these Notice: Undefined variable: row in blah on line 106 - 107 - 108 yeah $new is the connection to the db <?php require_once('/Connections/new.php'); ?> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 (edited) Try, <?php ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); ?> <?php session_start(true); ?> <?php require_once('/Connections/new.php'); ?> <?php /* if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = $_SESSION['MM_Username']; } mysql_select_db($database_new, $new); $query_Recordset1 = sprintf("SELECT * FROM appointments WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $new) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); */ ?> <title>Appointments</title> <style type="text/css"> body p { text-align: center; } body { background-image: url(slate.jpg); } .new { color: #FFF; } .new { font-weight: bold; } .new .new { text-align: left; } .new { color: #FFF; } .re { text-align: center; } .table .re { color: #FFF; } .table .re { color: #FFF; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" align="center"/> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> </p> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" align="center"/> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> </p> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a class="MenuBarItemSubmenu" href="success.php">Home</a> <li><a href="#">Gallery</a></li> <li><a class="MenuBarItemSubmenu" href="appointments.php">Visits</a> <li><a class="MenuBarItemSubmenu" href="#">Contact</a> </ul> <p align="center"><br> <br> </p> <p align="center"><img src="/images.jpg" width="323" height="156"><br /> <p align="center"> </p> <div align="center"> <span class="new"> <?php echo '<h2>Customer Appointments</h2>'; ?> </span></div><table width="1248" border="3" align="center"> <tr class="new"> <td width="116" class="re" style="text-align: center"><strong>Date Booked</strong></td> <td width="96" class="re" style="text-align: center"><strong class="table">Time Booked</strong></td> <td width="823" class="re" style="text-align: center"><strong class="table">Notes</strong></td> </tr> <?php $sql = sprintf("SELECT datebooked, timebooked, notes FROM appointments WHERE username='%s'", mysql_real_escape_string($_SESSION['MM_Username'])); $result = mysql_query($sql); // check query did execute without errors if ($result) { // output each file while ($row = mysql_fetch_assoc($result)): ?> <tr class="table"> <td class="re" style="text-align: center; color: #FFF;"><?php echo $row['datebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['timebooked']; ?></td> <td class="re" style="text-align: center"><?php echo $row['notes']; ?></td> </tr> </table> <span class="re"> <?php endwhile; // end the while loop // query did not execute, log or show error message } else { trigger_error('Cannot get users files from database: ' . mysql_error()); } mysql_free_result($result); ?> </span> Let me know if you get an error. Edited September 4, 2014 by jazzman1 Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Yeah thats it working Cheers m8 That only leaves the picture gallery Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 No errors? Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Nope, working 100% Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 then remove all commented lines by me Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 cool cheers m8 Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 4, 2014 Share Posted September 4, 2014 <?php echo '<h2>Customer Appointments</h2>'; ?> No need for php there... Quote Link to comment Share on other sites More sharing options...
mikosiko Posted September 4, 2014 Share Posted September 4, 2014 <?php echo '<h2>Customer Appointments</h2>'; ?> No need for php there... neither in another places... and several other fixes are necessary too... styles, in-line styles, duplicated lines (css, js), usage of TH instead of TD with styles, etc. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 take the closing </table> and <span class="re"> out of the while loop. what's the point of using the span element? styling the errors? Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 I have no idea lol I just used dreamweaver for all that styling and thats what it done Rough as hell I know, but next time in PDO stand by lol Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Will it be hard to incorporate mm_username into a pic gallery?I said a popup lastnight but I mean a new html page to display single pic Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 4, 2014 Share Posted September 4, 2014 Can they only access the picture gallery after logging in? If so just have session_start() at the top of the gallery script and access $_SESSION['MM_Username'] like you are in the above script. Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Hi CroNiXCheers for the reply. Is that your way of offering to help? As it stands, there is no script at the moment lol, I was hoping to amend what I have at the moment to make it work somehow as I like this idea Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Would this be easy to use for gallery with adding mm_username as I have added username to the table <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php mysql_connect ("localhost","root","1234"); mysql_select_db ("company"); $res=mysql_query ("select * from pictures"); echo "<table>"; while ($row=mysql_fetch_array($res)) { echo "<tr>"; echo "<td>";?> <img src="<?php echo $row["images1"]; ?> height "100" width "100"> <?php echo "</td>"; echo "<td>"; echo $row["name"]; echo "</td>"; echo "</td>"; echo "</tr>"; } echo "</table>" ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 (edited) Yeap, you got it. This is a pretty simple structure without any security, styling, javascript, etc.. but it would work. Get the image data (path,size,type, etc...) from a db table and display the image using an image tag. That's all you have to do. Try. It wouldn't hurt you Edited September 4, 2014 by jazzman1 Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 I got it working without using MM_Username, but since adding it in, I get Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\ridge\image2.php on line 38 <!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>Untitled Document</title> </head> <body> <?php session_START() ?> <?php mysql_connect ("localhost","username","password"); mysql_select_db ("company"); if (isset($_SESSION['MM_Username'])) { $row_username = $_SESSION['MM_Username']; $res=mysql_query ("select * from pictures"); echo "<table>"; while ($row=mysql_fetch_array($res)) { ?> echo "<tr>"; echo "<td>"; <img src="<?php echo $row["images1"]; ?>" height "100" width "100"> <?php echo "</td>"; echo "<td>"; echo $row["name"]; echo "</td>"; echo "</td>"; echo "</tr>"; } echo "</table>" ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 4, 2014 Share Posted September 4, 2014 (edited) while ($row=mysql_fetch_array($res)) { ?> //You are terminating php here, but using php on next line echo "<tr>"; So the very last ?> in the file doesn't have a matching open php tag...just 2 php close tags. Edited September 4, 2014 by CroNiX Quote Link to comment 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.