PHP - Displaying Data From Database Correctly!
ok so im sure this is only a small problem but still here it is:
im making a shopping list app where users can create a list...when they view the list they can populate it with categories such as frozen food, fruit, veg etc etc...they can then populate categories with items such as apples, potatoes or ice cream etc etc. now i have some data in the database already...and i wanted to display it on the page like this. ASDA SHOPPING LIST fruit apples bananas plums veg potatoes carrots frozen burgers chips ice cream however at the moment with my code it displays like this: ASDA SHOPPING LIST fruit apples bananas plums potatoes carrots burgers chips ice cream veg frozen here is my code: include_once("config_class.php"); $db = new db(); // open up the database object $db->connect(); // connect to the database //getting id of the data from url $id = $_GET['id']; $sql=mysql_query("SELECT listname FROM list WHERE listid=$id") or die("cannot select: ".mysql_error()); $sql2=mysql_query("SELECT catid, category FROM cat WHERE listid=$id") or die("cannot select: ".mysql_error()); $sql3=mysql_query("SELECT items.itemname, items.itemid, cat.catid FROM items, cat WHERE cat.catid=items.catid") or die("cannot select: ".mysql_error()); $temp_cat = ""; $res=mysql_fetch_array($sql); echo "<b>" . $res['listname'] . "</b>" . "<br><br>"; echo "<form action='addcat.php?id=$id' method='post'>"; echo "<input type='text' id='addcat' name='addcat'>"; echo "<input type='submit' value='Add Category'>"; echo "</form>"; while($res2=mysql_fetch_array($sql2)) { echo "<table cellpadding='2' cellspacing='2' width='800'>"; echo "<tr>"; if($res2['category'] != $temp_cat ) { echo "<td width='20%'>"; echo "<b>" . $res2['category'] . "</b>" . "</td>"; echo "<td width='20%'><a href='delcat.php?id=$res2[catid]&id2=$id'>Delete Category</a></td>"; echo "<form action='additem.php?id=$res2[catid]&id2=$id' method='post' name='form1'>"; echo "<td width='20%'>"; echo "<input type='text' name='itemname'></td>"; echo "<td width='20%'>"; echo "<input type='submit' name='Submit' value='Add Item'></td>"; echo "</form>"; echo "</tr>"; $temp_cat=$res2['category']; } while($res3=mysql_fetch_array($sql3)) { echo "<tr>"; echo "<td width='20%'>"; echo "$res3[itemname]" . "</td>"; echo "<td width='20%'>"; echo "<a href='delitem.php'>Delete Item</a>" . "</td>"; echo "</tr>"; } echo "</table>"; } could someone please help me display this correctly? thanks in advance Similar TutorialsOk I have some data that I would like to have grouped by date. There are dates that have multiple entries for the same date. I would like to have that data listed under one date. I would like it to look like this Date Location Weather Location Weather Date Location Weather Here is the code I have so far and it lists the data by date but only the data for first date in the table. If there is data listed for the same date but different location it will not list that data. What am I missing. Any help would be great. ! <?php // Connect to server and select database. include ("opendb.php"); $tbl_name="dbnwaterfowl"; $sql="SELECT huntDate, huntLocation, huntWeather, waterfowlSpecies, waterfowlNumberKilled, waterfowlBandedNumber, DATE_FORMAT(huntDate,'%m %d, %Y') FROM dbnwaterfowl GROUP BY `huntDate` ORDER BY `huntDate` ASC"; $result=mysql_query($sql); ?> <td> <p> </p> <table width="100%" border="2" cellpadding="1" cellspacing="0" bordercolor="#FA6103" bgcolor="#FFFFFF"> <tr> <td colspan="7"><div align="center"> <p><img src="images/hl-logo.jpg" /></p> <p align="center"><strong><a href="login.php">Login</a> | <a href="insert.php">Log Hunt</a> | <a href="logout.php">Logout</a></strong></p> </div></td> </tr> <tr> <td align="center" bordercolor="#FA6103" ><span class="style4">Hunting Date</span></td> <td align="center" bordercolor="#FA6103" ><span class="style4">Hunting Location</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Weather</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Waterfowl Species</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Number Killed</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Number of Bands</span></td> <td align="center"> </td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><? echo $rows['huntDate']; ?></td> <td><? echo $rows['huntLocation']; ?></td> <td><? echo $rows['huntWeather']; ?></td> <td><? echo $rows['waterfowlSpecies']; ?></td> <td><? echo $rows['waterfowlNumberKilled']; ?></td> <td><? echo $rows['waterfowlBandedNumber']; ?></td> <td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td> </tr> <?php } ?> </table> </td> </tr> </table> <?php mysql_close(); ?> PHP Code Code: [Select] <?php $username=""; $password=""; $database=""; mysql_connect("","",""); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM tablename"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $field1-name=mysql_result($result,$i,"id"); $field2-name=mysql_result($result,$i,"Location"); $field3-name=mysql_result($result,$i,"Property type"); $field4-name=mysql_result($result,$i,"Number of bedrooms"); $field5-name=mysql_result($result,$i,"Purchase type"); $field6-name=mysql_result($result,$i,"Price range"); echo "<b>$field1-name $field2-name2</b><br>$field3-name<br>$field4-name<br>$field5-name<hr><br>"; $i++; } ?> HTML code for the form Code: [Select] <table id="tb1"> <tr> <td><p class="LOC">Location:</p></td> <td><div id="LC"> <form action="insert.php" method="post"> <select multiple="multiple" size="5" style="width: 150px;" > <option>Armley</option> <option>Chapel Allerton</option> <option>Harehills</option> <option>Headingley</option> <option>Hyde Park</option> <option>Moortown</option> <option>Roundhay</option> </select> </form> </div> </td> <td><p class="PT">Property type:</p></td> <td><div id="PS"> <form action="insert.php" method="post"> <select name="property type" style="width: 170px;"> <option value="none" selected="selected">Any</option> <option value="Houses">Houses</option> <option value="Flats / Apartments">Flats / Apartments</option> </select> </form> </div> </td><td> <div id="ptype"> <form action="insert.php" method="post"> <input type="radio" class="styled" name="ptype" value="forsale"/> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent"/> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any"/> Any </p> </form> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td><div id="NB"> <form action="insert.php" method="post"> <select name="number of bedrooms"> <option value="none" selected="selected">No Min</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> to <select name="number of bedrooms"> <option value="none" selected="selected">No Max</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </form> </div> </td> <td><p class="PR">Price range:</p></td> <td><div id="PR"> <form action="insert.php" method="post"> <select name="price range"> <option value="none" selected="selected">No Min</option> <option value="50,000">50,000</option> <option value="60,000">60,000</option> <option value="70,000">70,000</option> <option value="80,000">80,000</option> <option value="90,000">90,000</option> <option value="100,000">100,000</option> <option value="110,000">110,000</option> <option value="120,000">120,000</option> <option value="130,000">130,000</option> <option value="140,000">140,000</option> <option value="150,000">150,000</option> <option value="160,000">160,000</option> <option value="170,000">170,000</option> <option value="180,000">180,000</option> <option value="190,000">190,000</option> <option value="200,000">200,000</option> <option value="210,000">210,000</option> <option value="220,000">220,000</option> <option value="230,000">230,000</option> <option value="240,000">240,000</option> <option value="250,000">250,000</option> <option value="260,000">260,000</option> <option value="270,000">270,000</option> <option value="280,000">280,000</option> <option value="290,000">290,000</option> <option value="300,000">300,000</option> <option value="310,000">310,000</option> <option value="320,000">320,000</option> <option value="330,000">330,000</option> <option value="340,000">340,000</option> <option value="350,000">350,000</option> </select> to <select name="price range"> <option value="none" selected="selected">No Max</option> <option value="50,000">50,000</option> <option value="60,000">60,000</option> <option value="70,000">70,000</option> <option value="80,000">80,000</option> <option value="90,000">90,000</option> <option value="100,000">100,000</option> <option value="110,000">110,000</option> <option value="120,000">120,000</option> <option value="130,000">130,000</option> <option value="140,000">140,000</option> <option value="150,000">150,000</option> <option value="160,000">160,000</option> <option value="170,000">170,000</option> <option value="180,000">180,000</option> <option value="190,000">190,000</option> <option value="200,000">200,000</option> <option value="210,000">210,000</option> <option value="220,000">220,000</option> <option value="230,000">230,000</option> <option value="240,000">240,000</option> <option value="250,000">250,000</option> <option value="260,000">260,000</option> <option value="270,000">270,000</option> <option value="280,000">280,000</option> <option value="290,000">290,000</option> <option value="300,000">300,000</option> <option value="310,000">310,000</option> <option value="320,000">320,000</option> <option value="330,000">330,000</option> <option value="340,000">340,000</option> <option value="350,000">350,000</option> </select> </form> </div> </td> </tr> </table> </div> <form id="submit" action=""> <input type="submit" value="search" /> </form> I am trying to display data from a database from a form entry here is the php <?php include('dbconnect.php'); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM child_info"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $field1-name=mysql_result($result,$i,"file_number"); $field2-name=mysql_result($result,$i,"first_name"); $field3-name=mysql_result($result,$i,"middle_name"); $field4-name=mysql_result($result,$i,"last_name"); $field5-name=mysql_result($result,$i,"birthdate"); $field6-name=mysql_result($result,$i,"gender"); $field7-name=mysql_result($result,$i,"features"); $field8-name=mysql_result($result,$i,"diagnosis"); $field9-name=mysql_result($result,$i,"description"); echo "<b>$field1-name $field2-name2</b><br>$field3-name<br>$field4-name<br>$field5-name<hr><br>"; $i++; } ?> here is the form I am using <form name="child_info" action="selectdata.php" method="post" id="child_info"> <table width="444" align="center" > <tr> <td> Search by Name: </td> <td> First Name:<input type="text" class="form-textbox " id="first_name" name="first_name" size="20" /><br /> Last Name:<input type="text" class="form-textbox " id="last_name" name="last_name" size="20" /> </td> </tr> <tr> <td width="208"> Choose Male or Female: </td> <td width="224"> <input type="radio" name="gender" value="male" /> Male <input type="radio" name="gender" value="Female" /> Female </td> </tr> <tr> <td> Choose age range: </td> <td> <select name="first_age" id="first_age"> <option value="00">From</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> </select> <select name="second_age" id="second_age"> <option value="00">To</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> </select> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <div align="right"> <input type="submit" name="submit" id="submit" value="submit" /> <input type="reset" name="reset" id="reset" value="reset" /> </div></td> </tr> </table> </form> first problem is getting the form to use the php second problem is when i try to use the php alone is I get this error Parse error: syntax error, unexpected '=' in /home/fathersh/public_html/selectdata.php on line 17 17 is highlighted above in the php So I have an simple account centre up, and i'm wanting to display their 'Name' 'Username' and 'Email' as part of their details. But I have one problem... My code doesn't seem to be getting the data from my database... It may be messy to some people, just warning you! Code: [Select] <?php session_start(); if($_SESSION['username']){ $connect = mysql_connect("****","****","****") or die("Could not connect to database."); mysql_select_db("****") or die ("Could not find database!"); $sql = mysql_query("SELECT * FROM login"); $username = $rows['username']; $email = $rows['email']; $rows = mysql_fetch_assoc($sql); echo "<p>"; } else header("location: suggestion.html"); ?> <!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> <link href="css/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-color: #CCC; } body,td,th { color: #000; font-family: "MS Serif", "New York", serif; } </style> </head> <body> <div id="wrap"> <!--Header--> <div id="header_member"> </div> <!--Log out and time--> <div id="info"> <div id="date"><script type="text/javascript"> var currentDate = new Date() var day = currentDate.getDate() var month = currentDate.getMonth() + 1 var year = currentDate.getFullYear() document.write("<b>" + day + "/" + month + "/" + year + "</b>") var currentTime = new Date() var hours = currentTime.getHours() var minutes = currentTime.getMinutes()</script> </div> <div id="time"><script type="text/javascript"> var suffix = "AM"; if (hours >= 12) { suffix = "PM"; hours = hours - 12; } if (hours == 0) { hours = 12; } if (minutes < 10) minutes = "0" + minutes document.write("<b>" + hours + ":" + minutes + " " + suffix + "</b>")</script> </div> </div> <div id="logout"><center><?php echo "<a href='logout.php'>Log out.</a>";?></center></div> <!--Main section which will contain everything else--> <div id="member_main"> <div id="member_right"><center> <p><img src="images/accountinf.png" width="175" height="30" /></p> <p>Name: <?php echo $username;?></p> <p>Email: <?php echo $email;?></p> </center> </div> <div id="member_top"><center><?php echo "Welcome, ".$_SESSION['username'];?></center></div> <div id="member_left" align="center"><img src="images/navigation.png" width="105" height="30" /><img src="images/home_member.png" width="105" height="30" /><img src="images/account.png" width="105" height="30" /></div> </div> <!--Footer--> <div id="footer_member"></div> </div> </body> </html> Hi, I'm trying to joing two tables together, in the resulting PHP coding (See below) the issue I'm having the coding saying select the colour from the colour table where the model of car is the same as the model in the cars table. For example, if the car model is KA and in the table it is KA show the colours. I know this manual fix does the trick. [ $test = "KA"; $query_cols = "SELECT * FROM colours WHERE colours.model = '$test' "; ] But not the soultion any help would be much appericated thank you. [ include "connections/dbconnect.php"; $manfactures = "Ford"; $car_query = "SELECT * FROM cars WHERE make = '$manfactures'"; $car_result = mysql_query($car_query) or die ("Error in query: $car_query. ".mysql_error()); setlocale(LC_MONETARY, 'en_GB'); $fmt = '%i'; if (mysql_num_rows($car_result) > 0) { while ($car_row = @ mysql_fetch_array($car_result)) { $test = "KA"; $query_cols = "SELECT * FROM colours WHERE colours.model = cars.model"; $cols_result = mysql_query($query_cols) or die ("Error in query: $query_cols. ".mysql_error()); print " <table class='details'> <tr> <td rowspan='2'> <img src=\"". $car_row["image"] ."\" alt='" . $car_row["image_alt"] . "' /> </td> <td colspan='2'> <a href='" . $car_row["what_link"] . "'> " . $car_row["model"]." ".$car_row["model_details"] . " </a> </tr> <tr> <td> <p class='info'> RRP:<br/> What Price:<br/> Our Price:<br/> Savings of:<br/> Delivery Time: </p> </td> <td> <p class='info1'> "; echo money_format($fmt, $car_row["rrp"] ); print "<br/>"; echo money_format($fmt, $car_row["what_price"] ); print "<br/>"; echo money_format($fmt, $car_row["our_price"] ); $savings = $car_row["rrp"] - $car_row["our_price"]; print " <br/> <font color=\"red\">"; echo money_format($fmt, $savings ); print " </font><br/> " . $car_row["delivery_time"] . " </p> </td> </tr> <tr> <td> "; while ($cols_row = @ mysql_fetch_array($cols_result)) { ?> <a href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $cols_row["colour"] . ""; ?>");return false'> <?php print " <img src=\"". $cols_row["colour_img"] ."\" alt='" . $cols_row["colour_img_alt"] . "' /> "; } print " </td> </tr> "; } } else { echo "Aids!"; } print "</table>"; ?>] Hey, I have written a script for a very simple PHP wall and comment system. This works fine but the problem I have is displaying the comments. It seems to display the comments associated with the post as well as the comments on the posts above it. I have checked the database and the post ID's are correct. Here is my code: Code: [Select] <?php $wallDisplay = ''; $commentDisplay = ''; $wallDisplaySql = mysql_query("SELECT * FROM wall WHERE to_id='$id' ORDER BY datetime DESC") or die (mysql_error()); while($row = mysql_fetch_array($wallDisplaySql)){ $wallPostId = $row["id"]; $to_id = $row["to_id"]; $from_id = $row["from_id"]; $message = $row["message"]; $dateTime = $row["datetime"]; $getFromData = mysql_query("SELECT username FROM members WHERE id='$from_id'") or die (mysql_error()); while($row2 = mysql_fetch_array($getFromData)){ $wallUsername = $row2['username']; } $displayComments = mysql_query("SELECT * FROM wallComments WHERE wallPostId='$wallPostId' ORDER BY datetime DESC"); while($row3 = mysql_fetch_array($displayComments)){ $wallComment = $row3['comment']; $commentFrom = $row3['from_id']; $commentDate = $row3['datetime']; $getUsername = mysql_query("SELECT username FROM members WHERE id='$commentFrom'"); while($row4 = mysql_fetch_array($getUsername)){ $commentUsername = $row4['username']; } $cheersCheck_pic = "members/$commentFrom/pic1.jpg"; $cheersDefault_pic = "members/0/defaultMemberPic.jpg"; if (file_exists($cheersCheck_pic)) { $cheers_pic = "<img src=\"$cheersCheck_pic?$cacheBuster\" width=\"40px\" />"; } else { $cheers_pic = "<img src=\"$cheersDefault_pic\" width=\"40px\" />"; } $commentDisplay .= '<table width="500px" align="right" cellpadding="4" bgcolor="#FFF"> <tr> <td width="10%" bgcolor="#FFFFFF"><a href="member_profile.php?id=' . $commentFrom . '">' . $cheers_pic . '</a><br /> </td> <td width="90%" bgcolor="#DBE4FD"><a href="member_profile.php?id=' . $commentFrom . '"><span class="blackText">' . $commentUsername . '</span></a> • <span class="blackTetx">' . $commentDate . '<br /><font size="1"></font></span><br /> <span class="blackText">' . $wallComment . '</span></td> </tr> </table>'; } $cheersCheck_pic = "members/$from_id/pic1.jpg"; $cheersDefault_pic = "members/0/defaultMemberPic.jpg"; if (file_exists($cheersCheck_pic)) { $cheers_pic = "<img src=\"$cheersCheck_pic?$cacheBuster\" width=\"40px\" />"; } else { $cheers_pic = "<img src=\"$cheersDefault_pic\" width=\"40px\" />"; } $wallDisplay .= '<table width="100%" align="center" cellpadding="4" bgcolor="#FFF"> <tr> <td width="7%" bgcolor="#FFFFFF"><a href="member_profile.php?id=' . $from_id . '">' . $cheers_pic . '</a><br /> </td> <td width="93%" bgcolor="#DBE4FD"><a href="member_profile.php?id=' . $from_id . '"><span class="blackText">' . $wallUsername . '</span></a> • <span class="blackTetx">' . $dateTime . '<br /><font size="1"></font></span><br /> <span class="blackText">' . $message . '</span></td> </tr> </table> <div id="commentList">' . $commentDisplay . '</div> <div id="comment" align="right"> <form id="comment" name="comment" method="post" action="member_profile.php?id=' .$id. '"> <textarea name="comment" id="comment" rows="1" cols="35"></textarea> <input type="hidden" name="wallPostId" id="wallPostId" value="'. $wallPostId .'" /> <input type="hidden" name="commentFrom" id="commentFrom" value="'. $_SESSION['id'] .'" /> <input type="submit" name="submitComment" id="submitComment" /> </form> </div><br /> '; } ?> I have been looking at it for ages but can think why this is happening. Thanks in advance for any help Hello freaks, Got a task here which is displaying correctly (I believe). I only have 3 data entries in the db right now. Like I said (I think) the display of the code below yields the right layout but it repeats the first db entry over and over. I got the display to work correctly like this: 1 2 3 4 5 6 7 8 9 I am trying to get this display result (so it is more eligable for the end user!) 1 4 7 2 5 8 3 6 9 Thanks in advance! CODE Code: [Select] <?php include_once "connect_to_mysql.php"; $cols = 3; $result = mysql_query("SELECT plantID, botanicalName FROM plants ORDER BY botanicalName"); $numrows = mysql_num_rows($result); $rows_per_col = ceil($numrows / $cols); $c = 1; $r = 1; while ($row = mysql_fetch_array($result)) { $plantID = $row["plantID"]; $botanicalName = $row["botanicalName"]; if ($r == $rows_per_col) { $c++; $r = 1; } else { $r++; } } $dyn_table = '<table width="750" cellpadding="0" cellspacing="0" border="0">'; for ($r = 1; $r <= $rows_per_col; $r++) { $dyn_table .= '<tr>'; for ($c = 1; $c <= $cols; $c++) { $dyn_table .= '<td><a href="plant_details.php?plantID = ' . $plantID . '" id="plantLink">' . $botanicalName . '</a></td>'; } $dyn_table .= '</tr>'; } $dyn_table .= '</table>'; ?> Hi, I think my problem is a mixture of MODREWRITE and PHP. I have the following .htaccess located in the web root. Code: [Select] RewriteEngine On RewriteRule ^about/(([^/]+/)*[^/.]+)$ /about/index.php?p=$1 [L] RewriteRule ^(([^/]+/)*[^/.]+)$ index.php?p=$1 [L] The index.php example below is located in the folder "about". Just for your info I also have an index at the web root too serving other files. <?php $page = isset($_GET['p']) ? $_GET['p'] : '/about/about'; switch($page) { /*----------------------- PAGES -----------------------------------*/ case 'about/profiles': $title = 'My Title'; $keyword = 'A few keywords'; $description = 'A good description.'; break; default: $title = 'My Title'; $keyword = 'A few keywords'; $description = 'A good description.'; break; } include($_SERVER['DOCUMENT_ROOT']. '/include/header.php'); include($_SERVER['DOCUMENT_ROOT']. 'about/'.$page.'.php'); include($_SERVER['DOCUMENT_ROOT']. "/include/footer.php"); ?> This is my problem: When I click on the link http://mysite.co.uk/about/ it throws the errors out below. When I click on the link http://mysite.co.uk/about/profiles/ it works fine and for the life of me I cant understand what I have done wrong. Warning: include(/var/www/mysite/about//about/about.php) [function.include]: failed to open stream: No such file or directory in /var/www/mysite/about/index.php on line 22 Warning: include() [function.include]: Failed opening '/var/www/mysite/about//about/about.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mysite/about/index.php on line 22 I am a kinda of newbie so any help/guidance will be gratefully received I am building a website out that shows videos. I would like to show the videos three up on a row, but it is instead stacking the videos one on top of the other. Check out the page here to get an understanding of what I am talking about http://theblusky.com/HOSTEDSITES/NOWSEASON/index.php?option=com_ttvideo&view=videolist&id=0&Itemid=107 The php file that is controlling the layout is attached. The site this is on is built using Joomla if that helps anyone. Any help is VERY MUCH APPRECIATED!!!! I have set up this website and there's a problem in displaying it. Can anybody help me out? I'm using PHP version 5.3. www.pchl.org Hi I appreciate everyone who helped me with my other problem trying to call my Array() I had issues with. Heres what that looks like http://crafted.horizon-host.com/ff/ Code from the above Code: [Select] <html> <head> <title>FINAL FANTASY XIV - Item Database</title> <style type="text/css"> a:link {text-decoration: none; color: #FFFFFF} a:visited {text-decoration: none; color: #FFFFFF} a:hover {text-decoration: none; color: #FFFFFF} a:active {text-decoration: none; color: #FFFFFF} p.title { font-size: medium; font-family: Verdana; color: #FFFFFF; } p.items { font-size: small; font-family: Verdana; color: #FFFFFF; } </style> <script src="http://static.yg.com/js/exsyndication.js" type="text/javascript"> </script> <script type="text/javascript"> YG.UserSettings.Syndication = { removeClasses: ['extern'], defaultClass: 'yg-iconsmall yg-name', clearTitle: true } </script> </head> <body background="../images/testbg.jpg" marginwidth=60 marginheight=60> <table align="center" id="Table_01" width=520 height=393 border=0 cellpadding=0 cellspacing=0> <tr> <td width=520 height=14 colspan=5 background="../images/test_01.gif"></td> </tr> <tr> <td width=20 height=23 background="../images/test_02.gif"></td> <td colspan=3 background="../images/test_03.gif" align="center" valign="middle"> <p class='title'>FINAL FANTASY XIV - Item Database</p> </td> <td width=14 height=23 background="../images/test_04.gif"></td> </tr> <tr> <td width=520 height=7 colspan=5 background="../images/test_05.gif"></td> </tr> <tr> <td background="../images/test_06.gif"></td> <td colspan=3 background="../images/test_07.gif" align="center" valign="top"> <p class='items'> <?php function grabdata($site){ $page_contents = file_get_contents($site); $pattern = '/\/item\/([a-z,-]+[^gil])\?id\=([0-9,]+)/'; preg_match_all($pattern, $page_contents, $matches); $arrRetList = array(); if(!empty($matches)){ foreach($matches as $item) { foreach($item as $pos => $row){ $arrRetList[$pos][] = $row; } } foreach($arrRetList as $row){ echo "<p class='items'><a href='http://ffxiv.yg.com" . $row[0] . "'>Unknown Item</a> - " . $row[1] . " - " . $row[2] . "<BR>"; } } } grabdata("http://ffxiv.yg.com/items?l=50:50;trd=0;cl=30"); ?> </p> </td> <td background="../images/test_08.gif"></td> </tr> <tr> <td colspan=2 width=23 height=17 background="../images/test_09.gif"></td> <td background="../images/test_10.gif"></td> <td colspan=2 width=17 height=17 background="../images/test_11.gif"></td> </tr> <tr> <td> <img src="../images/spacer.gif" width=20 height=1></td> <td> <img src="../images/spacer.gif" width=3 height=1></td> <td> <img src="../images/spacer.gif" width=480 height=1></td> <td> <img src="../images/spacer.gif" width=3 height=1></td> <td> <img src="../images/spacer.gif" width=14 height=1></td> </tr> </table> </body> </html> Heres the code im trying to run, has some added stuff to the above <?php ?> code but its not viewing at all, just shows a white page.. and would like to get some advice on what im doing wrong Code: [Select] <?php function grabdata($site){ $page_contents = file_get_contents($site); $pattern = '/\/item\/([a-z,-]+[^gil])\?id\=([0-9,]+)/'; preg_match_all($pattern, $page_contents, $matches); $arrRetList = array(); if(!empty($matches)){ foreach($matches as $item) { foreach($item as $pos => $row){ $arrRetList[$pos][] = $row; } } foreach($arrRetList as $row){ echo $row[1] . " - " . $row[2] . "<BR>"; echo "<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%'><td align='left'><p class='items'>Item</td><td align='center'><p class='items'>NPC Price</td><tr><td align='left'><p class='items'><a href='http://ffxiv.yg.com" . $row[0] . "'>Unknown Item</a></td></td><td align='center'><p class='items'>"; $page_contents2 = file_get_contents("http://ffxiv.yg.com" . $row[0] . ""); $matches2 = array(); preg_match_all('/<td class=\"lefttd\">Normal<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2); if ($matches2[1][0] == ""){ echo "0g - "; } else { print_r($matches2[1][0] . "g - "); } preg_match_all('/<td class=\"lefttd\">\+1<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2); if ($matches2[1][0] == ""){ echo "0g - "; } else { print_r($matches2[1][0] . "g - "); } preg_match_all('/<td class=\"lefttd\">\+2<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2); if ($matches2[1][0] == ""){ echo "0g - "; } else { print_r($matches2[1][0] . "g - "); } preg_match_all('/<td class=\"lefttd\">\+3<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2); if ($matches2[1][0] == ""){ echo "0g"; } else { print_r($matches2[1][0] . "g"); } echo "</td></tr>"; } echo "</table><BR><BR><BR>"; } } grabdata("http://ffxiv.yg.com/items?l=50:50;trd=0;cl=30"); ?> To give you a idea of what im looking for, it already grabs each item and list it from grabdata(""); function, i wanna take that further by it grabs the item, and then uses that data to grab the item sell price (normal, +1, +2, +3 quality) for each display it out, something like.. Code: [Select] ITEMNAME1 132g - 145g - 165g - 198g ITEMNAME2 50g - 0g - 0g - 0g ITEMNAME3 63g - 78g - 90g - 110g etc etc from the first $page_contents from $site $row[0] will output: item url variables $row[1] will output: item name $row[2] will output: item # from the second $page_contents from "http://ffxiv.yg.com" . $row[0] . "" $matches2[1][0] will be numerical output of the prices for each preg_match_all These scripts work separately just need them to work together I am having a slight problem with my dynamic form working in Internet Explorer 8. It functions properly in all browsers on Mac and Windows machines. I have a reservations form and when you choose a month in a drop down list, it dynamically creates another drop down with a list of reservation dates for that month. Well, in Internet Explorer it allows me to choose the month, but the second drop down never appears. All other browsers work fine. Anyone have any ideas?? Here is the pertinent code for index.php page... Code: [Select] <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } </script> <p align="left"> </p> <p align="left" class="home">Booking Form</p> <p align="left"><font size="2" face="Arial" color="#006600">Reservation Month:</font> <form action="resersend.php" method="post"> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Choose One</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br> <?php if(isset($_POST['submit'])){ $drop = $_POST['drop_1']; $tier_two = $_POST['tier_two']; echo "You selected "; echo $drop." & ".$tier_two; } ?></form> And here is the func.php page that works with index... Code: [Select] <?php //************************************** // Page load dropdown results // //************************************** function getTierOne() { $result = mysql_query("SELECT DISTINCT MONTH FROM daterange") or die(mysql_error()); while($tier = mysql_fetch_array( $result )) { echo '<option value="'.$tier['MONTH'].'">'.$tier['MONTH'].'</option>'; } } //************************************** // First selection results // //************************************** if($_GET['func'] == "drop_1" && isset($_GET['func'])) { drop_1($_GET['drop_var']); } function drop_1($drop_var) { include_once('db.php'); $result = mysql_query("SELECT * FROM daterange WHERE DEND > DATE(NOW()) AND STATUS='A' AND MONTH='$drop_var' ORDER BY DATE, SITE") or die(mysql_error()); echo '<select name="RID"> <option value=" " disabled="disabled" selected="selected">Choose a Reservation</option>'; while($drop_2 = mysql_fetch_array( $result )) { echo '<option value="'.$drop_2['RID'].'">'.$drop_2 ['DATE']. ', '.$drop_2 ['SITE']. ', '.$drop_2 ['PRICE'].'</option>'; } echo '</select> '; echo "</p>"; echo "<p align=left>"; echo "<br>"; echo "</select><p align=left><label><font size=\"2\" face=\"Arial\">First Name: <input type=\"text\" name=\"FNAME\" size=\"50\" maxlength=\"50\" tabindex=\"1\"<br>"; echo "<p align=left><label>Last Name: <input type=\"text\" name=\"LNAME\" size=\"50\" maxlength=\"50\" tabindex=\"2\"<br>"; echo "<p align=left><label>Address Line 1: <input type=\"text\" name=\"ADDR1\" size=\"50\" maxlength=\"50\" tabindex=\"3\"<br>"; echo "<p align=left><label>Address Line 2: <input type=\"text\" name=\"ADDR2\" size=\"50\" maxlength=\"50\" tabindex=\"4\"<br>"; echo "<p align=left><label>City: <input type=\"text\" name=\"CITY\" size=\"50\" maxlength=\"50\" tabindex=\"5\"<br>"; echo "<p align=left><label>State (abbrev.): <input type=\"text\" name=\"STATE\" size=\"2\" maxlength=\"2\" tabindex=\"6\"<br>"; echo "<p align=left><label>Zip Code: <input type=\"text\" name=\"ZIP\" size=\"5\" maxlength=\"5\" tabindex=\"7\"<br>"; echo "<p align=left><label>Contact Phone Number: (<input type=\"text\" name=\"PHONE1\" size=\"3\" maxlength=\"3\" tabindex=\"8\""; echo "<label>)<input type=\"text\" name=\"PHONE2\" size=\"3\" maxlength=\"3\" tabindex=\"9\""; echo "<label>-<input type=\"text\" name=\"PHONE3\" size=\"4\" maxlength=\"4\" tabindex=\"10\"<br>"; echo "<p align=left><label>Email: <input type=\"text\" name=\"EMAIL\" size=\"50\" maxlength=\"50\" tabindex=\"11\"<br>"; I'm trying to create a list that groups information by username. Only part of it is working. The first query ($get_item_sql) is grouping the information perfectly but the second query ($get_sold) is lumping the $item_price and $item_amount_due as one total for each one and outputting the same amounts into every username. I'm stuck on this and would appreciate your help. For example: Username item fees image fees item sales item price total due Jim 2 $0.40 $100.00 $3.00 $3.40 Kelly 5 $1.00 $100.00 $3.00 $4.00 This example shows the columns in red as being the problem where Kelly didn't sell anything so her "item sales" and "item price" should be $0.00 but is carrying Jim's totals into hers. Hope this helps! Thank you! $get_item_sql = mysql_query("SELECT id, username, date, ROUND(price,2) AS price, SUM(item_fee) AS fee, item_fee, SUM(sold) AS sales, SUM(ROUND(price,2)) AS total FROM product WHERE MONTH(date) = MONTH(DATE_ADD(CURDATE(),INTERVAL -1 MONTH)) GROUP BY username" ) or die(mysql_error()); if (mysql_num_rows($get_item_sql) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_info = mysql_fetch_array($get_item_sql)) { $item_username = $item_info['username']; $item_date = $item_info['date']; $item_price = $item_info['price']; $item_fee = $item_info['fee']; $image_fees = $item_fee * .20; $item_sold = $item_info['sales']; $get_sold = mysql_query("SELECT SUM(ROUND(price,2)) AS total, SUM(ROUND(sold,2)) AS sales, date, username FROM product WHERE sold = '1' AND MONTH(date) = MONTH(DATE_ADD(CURDATE(),INTERVAL -1 MONTH)) GROUP BY username") or die(mysql_error()); if (mysql_num_rows($get_sold) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid item, get info while ($item_sold2 = mysql_fetch_array($get_sold)) { $item_sales = $item_sold2['total']; $item_price = ($item_sold2['total']) * .03; $item_amount_due = $image_fees + $item_price; $content .= "<form action=\"add_artist.php\" method=\"post\"><table class=\"anotherfont\" width=\"670\" border=\"0\"> <tr><td width=\"201\">{$item_username}</td> <td width=\"109\">{$item_fee}</td> <td width=\"109\">{$image_fees}</td> <td width=\"109\"> {$item_sales}</td> <td width=\"109\"> {$item_price}</td> <td width=\"109\"><input name=\"balance_due\" type=\"text\" value=\"{$item_amount_due}\" /></td> </tr><br /></table></form>"; } } } } I've got a simple internal messaging system that I'm trying to get the text to display the way it was entered when a message was sent. The messages are inserted into the database using variables generated through this function: Code: [Select] <?php function safe($value){ return mysql_real_escape_string($value); } $staffid=form($_POST['staffid']); $from=safe($_POST["from"]); $category=form($_POST['category']); $subject=safe($_POST["subject"]); $message=safe($_POST["message"]); $grade=form($_POST['grade']); ?> when the text is inserted, there are back slashes automatically inserted behind certain punctuation marks. For example, is someone sends a message that says, "Someone's using phpfreaks forums." It would be inserted as, "Someone\'s using phpfreaks forums." How can I stop this from happening? Or how can I remove the "\" when displaying the string on the web page? Any help is greatly appreciated. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=352551.0 Hi! I'm a total stupid newbie. Please humor me. So, I'm trying to make a guestbook, just as practice. So far I have a form that writes entries to a file, each entry on a new line. Entries look like this: Code: [Select] 11:11 am, Oct 12th, 2010|name|website|message My dividing character between parts of the entries is the vertical bar. I don't know if that's a bad idea. As I said, I'm a newb. I should probably find out how to make a code that makes it so people can't use that character in the form. Anyway, this is my code so far trying to display the entries. So far, I just want to show the date of the first entry. $file = fopen("posts.txt", 'rb'); while(!feof($file) && fgetc($file) != "|"){ $date = $date.fgetc($file); } echo $date; fclose($file); I already have a problem. The code does stop at the vertical bar, but instead of showing the date as "11:11 am, Oct 12th, 2010" it shows "11 m c 2h 00". I'm just super confused, and I don't know what to do. Thanks. (: Hi there,
I'm a bit of a noobie, and I have a class which will allow me to send an email in html.
However when I send an email with a link such as <a href="http://www.google.com">link</a> using the html() function
The email is sent and everything is displayed corrected.
However the link isn't clickable.
Here is the code for the class.
<? class eMail { var $to = array(); var $cc = array(); var $bcc = array(); var $attachment = array(); var $boundary = ""; var $header = ""; var $subject = ""; var $body = ""; function eMail($name,$mail) { $this->boundary = md5(uniqid(time())); $this->header .= "From: $name <$mail>\n"; } function to($mail) { $this->to[] = $mail; } function cc($mail) { $this->cc[] = $mail; } function bcc($mail) { $this->bcc[] = $mail; } function attachment($file) { $this->attachment[] = $file; } function subject($subject) { $this->subject = $subject; } function text($text) { $this->body = "Content-Type: text/plain; charset=ISO-8859-1\n"; $this->body .= "Content-Transfer-Encoding: 8bit\n\n"; $this->body .= $text."\n"; } function html($html) { $this->body = "Content-Type: text/html; charset=ISO-8859-1\n"; $this->body .= "Content-Transfer-Encoding: quoted-printable\n\n"; $this->body .= "<html><body>\n".$html."\n</body></html>\n"; } function send() { // CC $max = count($this->cc); if($max>0) { $this->header .= "Cc: ".$this->cc[0]; for($i=1;$i<$max;$i++) { $this->header .= ", ".$this->cc[$i]; } $this->header .= "\n"; } // BCC $max = count($this->bcc); if($max>0) { $this->header .= "Bcc: ".$this->bcc[0]; for($i=1;$i<$max;$i++) { $this->header .= ", ".$this->bcc[$i]; } $this->header .= "\n"; } $this->header .= "MIME-Version: 1.0\n"; $this->header .= "Content-Type: multipart/mixed; boundary=$this->boundary\n\n"; $this->header .= "This is a multi-part message in MIME format\n"; $this->header .= "--$this->boundary\n"; $this->header .= $this->body; // Attachment $max = count($this->attachment); if($max>0) { for($i=0;$i<$max;$i++) { $file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i])); $this->header .= "--".$this->boundary."\n"; $this->header .= "Content-Type: application/x-zip-compressed; name=".$this->attachment[$i]."\n"; $this->header .= "Content-Transfer-Encoding: base64\n"; $this->header .= "Content-Disposition: attachment; filename=".$this->attachment[$i]."\n\n"; $this->header .= chunk_split(base64_encode($file))."\n"; $file = ""; } } $this->header .= "--".$this->boundary."--\n\n"; foreach($this->to as $mail) { mail($mail,$this->subject,"",$this->header); } } } ?> Hi i am trying to order data however i get a problem. The problem is that it orders the data but only by the first number! Example: (Place 1) Freid001: 981 (Place 2) mark: 90000 (Place 3) Tom: 5 (Place 4) Ash 1000 Here is the code i am using: $query = "SELECT * FROM Game ORDER BY XP"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo "<table border='0'>"; echo "<tr> <th>User</th> <th>XP</th> </tr>"; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "</td><td>"; echo $row['User'] ; echo "</td><td>"; echo $row['XP']; } echo "</table>"; ?> Thanks Ok Here is my Problem the following works great except it does not add the $user var to the account_details. As well as outputs md5 wrong it outputs something but its different than the password should be. Heres my PHP code: Code: [Select] <?php session_start(); /** * @author Brian T. Flores * @copyright 2010 - 2014 */ error_reporting(E_ALL); $conn = mysql_connect($db_host, $db_user, $db_pass) or die ('Error connecting to mysql'); mysql_select_db($db_name); if($_GET['goahead']==1){ // If GoAhead Is set if(isset($_GET['user'])){ // If isset GoAhead $user = mysql_real_escape_string($_GET['user']); // Clean User for Transfer. $user_check = mysql_query("SELECT * FROM `account_details` WHERE `username01` = '$user'"); // Check to see if username is taken. $ucount = mysql_num_rows($user_check); // Get Username Check Count if($ucount!=""){ // If Username is Taken. die(3); // Die Error Number 3 } // End If Username is Taken. if(isset($_GET['pass'])){ // If password is set. $pass = mysql_real_escape_string($_GET['pass']); // Clean Password for Transfer. $encPass = md5($pass); // Encrypt Password if(isset($_GET['race'])){// If Race is Set. $race = mysql_real_escape_string($_GET['race']); // Clean Race for Transfer. if(isset($_GET['email'])){ // If Email is set. $email = mysql_real_escape_string($_GET['email']); // Clean Email for Transfer. $email_check = mysql_query("SELECT * FROM `account_details` WHERE `email` = '$email'");// Check to see if Email is Taken. $ecount = mysql_num_rows($email_check); // Get Email Check Count. if($ecount!=""){ // If Email is Taken. die(2); // Die Error Number 2 } // End If Email is Taken. if(isset($_GET['email2'])){ // If email confirmation is set. $email2 = mysql_escape_string($_GET['email2']); // Clean Email Confirmation for Transfer. if($email == $email2){ // If emails match. if(isset($_GET['planet'])){ // If Planet Name is Set. $pname = mysql_real_escape_string($_GET['planet']); // Clean Planet Name for Transfer. if(isset($_GET['security_code'])){ // If Security Code Input is set. $security_code = mysql_real_escape_string($_GET['security_code']); // Clean Security Code. $security_enc = md5($security_code); // Encrypt Security Code. $security_code2 = $_SESSION['image_random_value']; // Get Security Code Session if($security_enc == $security_code2){ // If Codes Match. $randActive = rand(11111111111111111111,99999999999999999999); // Get Activation Link pre-encrypt. $activation_link = md5($randActive); // Get Encrypted Activation Link. $q = "INSERT INTO `account_details` (`username01`, `password01`, `loggedIn`, `currentlyLogged`, `active`, `activelink`, `race`, `email`) VALUES ('$user', '$encPass', 0, 0, 0, '$activation_link', '$race', '$email');"; // ^ Add Account Query. $res = mysql_query($q) or die("Error Detected! <br />".mysql_error()); // ^ Add Account to SQL. $q = mysql_query("SELECT * FROM `account_details` WHERE `username01` = '$user'")or die(mysql_error()); // ^ Get Information from New Account. $newuserinfo = mysql_fetch_array($q);// Get New User Information $id = $newuserinfo['id']; // Set New Account Id. $q="INSERT INTO `planets` (`owner`, `name`, `recource1`, `recource2`, `recource3`, `recource4`, `recource5`, `turns_01`, `untrained_units_01`, `attackers_01`, `defenders_01`, `miners_01`, `covert_01`, `anticovert_01`, `ship_01`, `ship_02`, `ship_03`, `ship_04`, `ship_05`, `ship_06`, `ship_07`, `building01`, `building02`, `building03`, `building04`, `building05`, `building06`, `building07`, `building08`, `building09`) VALUES ('$id', '$pname', 35000, 15000, 12000, 135000, 125000, 220, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);"; // ^ Add Planet Query. $res2 = mysql_query($q) or die("Error Detected! <br />".mysql_error()); // Add Planet to SQL. $body = " Hello ".$user.", Congradulations! Your account on Ultimate Conquest has been Registed Today! Click the following Link to Activate Account: http://testing.ultimateconquest.net/activate.php?code=".$activation_link." If you have not registered an account and have found this message in error please click the following link to report this error: http://testing.ultimateconquest.net/errorreg.php?account=".$user." Thank you for registering for Ultimate Conquest - ULC, Head Admin Brian Flores AKA Photonic.... "; // Activation Email Information. if (mail($email, "Activate your ULC Ultimate Conquest Account! No-Reply!", $body)) { // If Email Is Sent. die("1"); // Die Error Number 1 } // End Send Email }else{ // If Security Codes do Not Match. die("12"); // Die Error Number 12 } }else{ // If Security Code is Not Set die("11"); // Die Error Number 13 } }else{ // If Planet Name is Not Set. die("10"); // Die Error Number 10. } }else{ // If Emails do not match. die("9"); // Die Error Number 9. } }else{ // If email confirmation is not set. die("8"); // Die Error Number 8. } }else{ // If email is not set. die("7"); // Die Error Number 7. } }else{ // If race is not set. die("6"); // Die Error Number 6. } }else{ // If Password is not set. die("5"); // Die Error Number 5. } }else{ // If Username is not set. die("4"); // Die Error Number 4. } }else{ // If GoAhead is Not Set. die("Go Ahead Not Established By Game System!"); } ?> Here is the Register Function in Javascript: Code: [Select] function regMast(){ var user = document.getElementById('username_client').value; var pass = document.getElementById('password_client').value; var race1 = document.getElementById('races1').value; if(race1 !=""){var race = document.getElementById('races1').value;} var race2 = document.getElementById('races2').value; if(race2 !=""){var race = document.getElementById('races2').value;} var race3 = document.getElementById('races3').value; if(race3 !=""){var race = document.getElementById('races3').value;} var race4 = document.getElementById('races4').value; if(race4 !=""){var race = document.getElementById('races4').value;} var planet_name = document.getElementById('pname').value; var email = document.getElementById('email').value; var email2 = document.getElementById('email2').value; var security_code = document.getElementById('security_code').value; var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var returni = ajaxRequest.responseText; if(returni == "1"){ document.getElementById('reg_error').innerHTML = 'Registration Completed! Check Activation Email for more information.'; } if(returni == "2"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Email Address Already Taken!'; } if(returni == "3"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Username Already Taken!'; } if(returni == "4"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Username Field Empty!'; } if(returni == "5"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Password Field Empty!'; } if(returni == "6"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! You must select a race!'; } if(returni == "7"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Email Field Empty!'; } if(returni == "8"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Email Confirmation Field Empty!'; } if(returni == "9"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Emails did not Match!'; } if(returni == "10"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Planet Name Field Empty!'; } if(returni == "11"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! You did not Input the Security Code!'; } if(returni == "12"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! The Security Code you Inputed did not Match the Image!'; }else{ document.getElementById('reg_error').innerHTML = returni; } } } var queryString = "?goahead=1&user=" + user + "&pass=" + pass + "&race=" + race + "&email=" + email + "&email2=" + email2 + "&security_code=" + security_code + "&planet=" + planet_name; ajaxRequest.open("GET", "register.php" + queryString, true); ajaxRequest.send(null); } 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. |