PHP - Need Help Counting Rows In Html Table.
I know how much you guys hate people asking for help without any starting code but I'm not even sure how to start this..
I want a script to read this page and count all the admins and referees. If anyone is willing to help, here's a sample of the html code: Code: [Select] <div class="boxInner"><h3>Arena Referees</h3><table class="list"><thead><tr><th style="width:16px;"></th><th style="width:150px;">Name</th><th style="width:300px;">Position</th><th style="width="150px;">Gamertag</th></tr></thead><tbody><tr><td><a href="http://gamebattles.com/profile/GottaHaveFaith78"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td class="alt1">Faith</td><td><b>Head Referee</B></td><td class="alt1">GB CombatBarbie</td></tr><tr><td class="alt2"><a href="http://gamebattles.com/profile/Jack.-"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td>Jack</td><td class="alt2"><b>Asst. Head Referee</b></td><td>Get Jacked x</td></tr><tr><td><a href="http://gamebattles.com/profile/amghawk"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td class="alt1">Mike</td><td><b>Asst. Head Referee (IS)</b></td><td class="alt1">GB amghawk</td></tr><tr><td class="alt2"><a href="http://gamebattles.com/profile/cory94bailly"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td>Cory</td><td class="alt2">Referee</td><td>Cory xz</td></tr><tr><td><a href="http://gamebattles.com/profile/crago"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td> I'm just wondering how I could even count them. Any help will be appreciated, thanks. Similar TutorialsHi, I have a problem regarding counting rows in a mysql table. Here is the code: Code: [Select] <?php require_once('includes/connection.inc.php'); $conn = dbConnect('read'); $check = 'SELECT COUNT(*) FROM images'; $checkRes = $conn->query($check) or die(mysqli_error()); if($checkRes <= 0) { header('Location: empty_blog.php'); // redirect to another page } else { // do something else... } ?> The error I'm getting: "Notice: Object of class mysqli_result could not be converted to int in C:\xampp\htdocs\photoblog\index.php on line 6" Any help is greatly appreciated! Hello I have a table that inserts a new row with data when a member views a page. I wish to count all the rows for each member, and then be able to show what the cuurent members "position" is eg. what members has the highest row count. Example. counting the rows for member_A returns 1000 rows, the number of rows for member_B returns 1500 rows. How can I display for member_A that he is in "second" place? Hi I'm using php file to retrieve the amount of records in my database, but all of a sudden I get 0 results. It worked fine a few days ago. I got PHP 5.2.* on my host. Here is the current script that I use.
Did I made a mistake somewhere?
<?php $con=mysqli_connect("******","*****","*****","****"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="SELECT * FROM mxit"; if ($result=mysqli_query($con,$sql)) { $rowcount=mysqli_num_rows($result); //printf("Result set has %d rows.\n",$rowcount); // Free result set mysqli_free_result($result); } mysqli_close($con); ?> Folks, Having trouble here. Forgot how you use the COUNT. Not interested in the num_rows due to it being slow compared to COUNT. I have users table like this: id|username|sponsor_username 0|barand|requinix 1|phpsane|alison 2|mickey_mouse|requinix Now, I want to check if a sponsor username exists or not. Such as does the entry "requinix" exists or not in one of the rows in the "sponsor_username" column. In our example it does twice and so the variable $sponsor_username_count should hold the value "2". Else hold "0". I get error: Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1
My code:
$stmt_1 = mysqli_prepare($conn,"SELECT COUNT(sponsor_username) from users = ?"); mysqli_stmt_bind_param($stmt_1,'s',$sponsor_username_count); mysqli_stmt_execute($stmt_1); //Show error if 'users' tbl was not successfully queried". if (!$stmt_1) { echo "ERROR 1: Sorry! Our system is currently experiencing a problem loading this page!"; exit(); } else { mysqli_stmt_bind_result($stmt_1,$sponsor_username_count); mysqli_stmt_fetch($stmt_1); mysqli_stmt_close($stmt_1); //Check if Sponsor Username in Url ($_GET) is already registered or not. If not then show "Invalid Url" or Link message. if ($sponsor_username_count < 1) { echo "<b>Invalid Url or Link!<br> Invalid Sponsor: \"$sponsor_username\"!</b><?php "; exit(); } }
Alright, I need to find a way to display the top ten duplicated rows for a table in my database. I have tried multiple methods but I have failed. Can you please assist me with this problem. I currently run a query in phpmyadmin to get the result, but i cant figure out how to properly code the php script. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=343705.0 I wish to have a page that will display a form if there aren't already enough registrations in the database. The following it an outline of how it will be: <?php require_once "../scripts/connect_to_mysql.php"; //this works fine // Count how many records in the database (1) $sqlCommand = "SELECT * FROM teams"; (2) $sqlCommand = "SELECT COUNT (*) FROM teams"; (3) $sqlCommand = "SELECT COUNT (id) FROM teams"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); (1) $numRegistrations = mysql_num_rows($query); //Count how many rows are returned from the query above (2) $numRegistrations = $query (3) $numRegistrations = mysql_num_rows($query); mysqli_free_result($query); ?> (Some HTML code, like DOCTYPE, head, start of body tags) <?php if($numRegistrations > 35){ echo "Sorry, registrations for this event is at it's maximum."; }else{ ?> <form blah blah blah> </form> <?php } ?> (end of body and html tag) You'll see above there is (1), (2), (3). These are the main 3 that I've been trying, and they match up the $sqlCommand to the $numRegistrations. What would be the problem with this code? I use wamp server to test, have been using it for ages. Chrome browser to test in. If I remove the database query, the rest of the page will load. With the query in there, only the HTML code up until the database query is parsed, so therefore nothing is display on the page. Please help. Thanks Denno Hi,
I am trying to make a list of all countries listed in a database and the number of times they appear. But I am clearly doing something wrong as I am not able to list out the number of times that they appear.
This is what I have got so far:
<h4>Countries</h4> <table><col width='150px'><col width='150px'> <tr> <th> Country </th> <th> Number of Occurences </th> </tr> <?php $location = DB::getInstance()->query("SELECT country, COUNT(country) as countCountry FROM users GROUP BY country ORDER BY count DESC"); foreach ($location->results() as $locations) { echo "<tr><td>"; echo $locations->country; echo "</td><td>"; echo $locations->countCountry; echo "</td></tr>"; } ?> </table>Can anyone point me in the right direction? I am in need of suggestions on how too achive this: I have a surf exchange and whenever a member has viewv a site, it ads this members Id and time to a table called vtp_tracking. I have now created a team script, so I can count the total of surf for members within this team from the vtp_table. What I am in need of is this: I would like to add a bonus for the teams, so my idea was this: every hour run a cronjob to get the results for the last hour by team id lik so: Code: [Select] WHERE vtp_members.team_id="teamid" AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>date_sub(NOW(),interval 60 minute I believe the above code will work fine and get me the results for team members for the last hour. Problem: how can I get this result, multiple it with the value from another field and divide by 100 and add this to a third field? eg: (result from above * value from other field / 100) then add to a third field. Anyone willing to try and answer this one? Hi, I'm trying to get a number of different keywords from many table fields, and i want to count them according to the occurrence of each keyword, so it should be like (keyword1 occurred 10 times for example ). the problem is when i use count in for loop: Code: [Select] $tags = explode("|", $row[0]); $i=1; $count = 0; for($i; $i<count($tags); $i++){ print "$count {$tags[$i]}<br />"; $count++; } it counts the occurrence of key words in each field separately from the rest (i.e. Code: [Select] 0 day 1 night 0sun 1 moon 0 clouds 1 rain ) 2 keywords in each field (some other fields got more). I want the count to be more like: Code: [Select] 1 day 2 night 3 sun 4 moon 5 clouds 6 rain thanks I have 2 queries that I want to join together to make one row
On my site, I currently have a page that lists my team's fixtures: http://www.cfrclunj.co.uk/fixtures.php As can be seen, in between each separate month there is a row of blank, grey cells. I am now updating the site so that it takes all information from a database (for easier update). On my test page (at bottom) I have recreated the fixtures table using my db: http://www.cfrclunj.co.uk/db_test.php What I am wondering is if there is any way to get the grey monthly separater row into my table. Could this be done by inserting a row of data into the db table that uses an if statement to change it's appearance? Or could I somehow use MYSQL/PHP to make it put a row in for each separate month? I have to admit my PHP and MYSQL skills are still at a very basic level, and so any help would be great! I wonder if anyone can help me, I have a MySQL table of football teams (team_name; link; description; rival_1; rival_2; rival_3;) where each 'team_name' has its own page with the relevant information from the table and is named as the link field from the table. Within each team page I also want to display the rival_1,2 and 3 teams with links to their pages. I know how to just display the information but am struggling with picking up the link from the relevant row in the table. Is this possible or would I be better off just placing a <a href> link around each rival team when I enter it into the MySQL table?? I hope this makes sense, any help would be very much appreciated. Thanks hi i have table in my database holding food items. i need users to be able to order those items individually for example...if apples are third from the top..they should be able to move them up or down the list 1 place at a time perhaps with an up and down arrow. i have a field in my table called item_order the only problem is...users are going to be able to insert new items to the database...but i dont know how they can populate the order field...i cant set it to auto increment because the item_id is the primary key auto incrementing...how can i populate the order field? and then once i have this problem sorted how do i then allow users to change this order? im looking for code if possible please because ive spent WAY to long on this now and im struggling to grasp things people advise me to do. terminology and methods of accomplishing this are just going over my head. please help. Hi, I'm using a table to list results from a MySQL query. I wanted to make the rows of the table alternate colours and found the following code on this website which does the job perfectly: $counter++; $bgcolor = ($counter % 2)?"#e8edff":"#ffffff"; echo "<tr class='border'>\n <td bgcolor='".$bgcolor."'>$n</td>\n <td bgcolor='".$bgcolor."'>$player</td>\n <td bgcolor='".$bgcolor."'>$score</td>\n </tr>\n"; On my webpage i have six tables listing results from six MySQL queries and i use the above code after each query to construct the table and alternately colour the rows blue then white. My problem arises when there are an odd number of rows in the first table. This results in the first row of the second table being coloured white, not blue. I would like the first row of each table to be blue. Is there a simple way to reset the counter for each table? Any advice much appreciated. Thanks. Hi all, I have a data base with the following table: ---member_data--- id ^ mid ^fieldname^ fieldvalue 1 - 2 - applicant - Seth Smith 2 - 4 - firstname - Chris 3 - 4 - lastname - Cooper 4 - 7 - full_name - Joey Jones 5 - 7 - occupation - Programmer 6 - 7 - phone - 800-555-1212 And below is a snippet that I use to display the selected members data for editing ------------------------------- <table> <tr> <td>Name:</td> <td>Value:</td> </tr> <?php $query = "SELECT * FROM member_data WHERE mid='$mid'"; $result= mysql_query($query); while($row = mysql_fetch_array($result)) { $fieldname = $row["fieldname"]; $fieldvalue = $row["fieldvalue"]; ?> <tr> <td><input type="text" name="<?php echo $fieldname;?>" value="<?php echo $fieldname;?>"></td> <td><input type="text" name="<?php echo $fieldvalue;?>" value="<?php echo $fieldvalue;?>"></td> <?php } ?> </tr> </table> ------------------------------- My question is: - using the Db example above: - lets say Ive selected mid#7 (member id 7) to edit which is displayed using the snippet code from above. - once displayed how do I edit mid#7 given the fact that mid#7 is located on 3 seperate rows from the same table? Thank you, Dave *ALSO - I tried the snippet below which did Not work. foreach($_POST as $key => $val) { $sql = "UPDATE member_data SET fieldname='$key', fieldvalue='$val' WHERE mid='$mid'"; $result = mysql_query($sql); } Hi all, So I'm not completely sure on how to do this, but basically this i what i want. I want the users to be able to create "fields" in my table, so let's say we have a structure like this: Field 1 Field 2 Field 3 Data 1 Data 2 Data 3 Problem is, that i want my users to update both the <td> and <tr> information via mysql, without altering the database. And I'm not sure on how I can make sure, that everything gets out in the right order. I have this so far: Code: [Select] <table id="sort-table"> <thead> <tr> <?PHP echo ' <td> Identifier </td> '; $result = mysql_query("SELECT * FROM fields ORDER BY `order`"); while($row = mysql_fetch_array($result)) { echo ' <td> ' . $row["name"] . ' </td> '; } ?> <th style="width:128px">Options</th> </tr> </thead> This will display the field 1, 2, 3 etc.. My problem is.. How do i get the content displayed in the right order to the right fields.. :/ I hope you understand me, if not, please tell me so I can elaborate ^_^ I know this might seems like a noob question, and I'm sorry that I couldn't search, but I didn't know what to search for. Hi, I'm very new to these forums and php alike. I've been working on this bit of code for weeks now. I've written numerous versions and made endless revisions; trying pieces from many similiar source and well, it's still not quite working out for me. The form I've been trying to finish will have multiple rows. The user will input values specific to each row, but I'm trying to make it so that each row is synonymous with each other in regard to the database table. Like an order form, an inventory form, or a roster. I'd really like to make this code work out because I can think of numerous applications for it's use. I'm sure others could use it for even more. So, as you see; the html code represents the table that contains the form. Currently, I only have five of these rows in the form, but would like for anybody using the code to be able to add in code for as many rows in the table as needed. Code: [Select] <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <FORM action="post_multiple.php" method="POST"> <table width="80%" border="1"> <tr> <td>Vendor</td> <td>Item Description</td> <td>Quantity</td> <td>Price</td> </tr> <tr> <td><select name="vendor" id="vendor" > <option value="other1">other1</option> <option value="other2">other1</option> <option value="other3">other3</option> <option value="other4">other4</option> <option value="other5">other5</option> </select></td> <td><input name="description" type="text" id="description" size="50" /></td> <td><input name="quantity" type="text" id="quantity" size="50" /></td> <td><input name="price" type="text" id="price" size="50" /></td> </tr> <tr> <td><select name="vendor" id="vendor"> <option value="other1">other1</option> <option value="other2">other1</option> <option value="other3">other3</option> <option value="other4">other4</option> <option value="other5">other5</option> </select></td> <td><input name="description" type="text" id="description" size="50" /></td> <td><input name="quantity" type="text" id="quantity" size="50" /></td> <td><input name="price" type="text" id="price" size="50" /></td> </tr> <tr> <td><select name="vendor" id="vendor"> <option value="other1">other1</option> <option value="other2">other1</option> <option value="other3">other3</option> <option value="other4">other4</option> <option value="other5">other5</option> </select></td> <td><input name="description" type="text" id="description" size="50" /></td> <td><input name="quantity" type="text" id="quantity" size="50" /></td> <td><input name="price" type="text" id="price" size="50" /></td> </tr> <tr> <td><select name="vendor" id="vendor"> <option value="other1">other1</option> <option value="other2">other1</option> <option value="other3">other3</option> <option value="other4">other4</option> <option value="other5">other5</option> </select></td> <td><input name="description" type="text" id="description" size="50" /></td> <td><input name="quantity" type="text" id="quantity" size="50" /></td> <td><input name="price" type="text" id="price" size="50" /></td> </tr> <tr> <td><select name="vendor" id="vendor"> <option value="other1">other1</option> <option value="other2">other1</option> <option value="other3">other3</option> <option value="other4">other4</option> <option value="other5">other5</option> </select></td> <td><input name="description" type="text" id="description" size="50" /></td> <td><input name="quantity" type="text" id="quantity" size="50" /></td> <td><input name="price" type="text" id="price" size="50" /></td> </tr> <tr> <td><select name="vendor" id="vendor"> <option value="other1">other1</option> <option value="other2">other1</option> <option value="other3">other3</option> <option value="other4">other4</option> <option value="other5">other5</option> </select></td> <td><input name="description" type="text" id="description" size="50" /></td> <td><input name="quantity" type="text" id="quantity" size="50" /></td> <td><input name="price" type="text" id="price" size="50" /></td> </tr> </table> <input type="submit" name="Submit" value="Submit" /> </FORM> </body> </html> In the php script I've tried using the count, loop, if, several others functions to try to get it to insert all the completed rows from the form into the table but just can't seem to get it to work out. Anyways, here's a representation of what i'd like to achieve. Not necessarily the code I've written trying to accomplish this, I'd have to upload a book if that were the case. <?php ini_set('display_errors','On'); error_reporting(E_ALL); $host="localhost"; // Host name $username="root"; // Mysql username $password="password"; // Mysql password $db_name="testing"; // Database name $tbl_name="test_multiple"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //declarations $vendor = $_POST['vendor']; $description = $_POST['description']; $quantity = $_POST['quantity']; $price = $_POST['price']; // Check if button name "Submit" is active, do this $sql1="INSERT INTO $tbl_name (vendor, description, quantity, price) VALUES ('".$vendor."', '".$description."', '".$quantity."', '".$price."')"; $result1=mysql_query($sql1); mysql_close(); ?> If anybody can suggest where I need to go with that, that would be great. Like I said above, I've tried about everything I could find any reason to from forum threads I had found in google searches and whatnot. Also, if there is a good article, link or tutorial that would address this that anybody knows about that would be great. However, I'm not looking for a link to a product or plugin that will do this stuff for me. I'm trying to get halfway decent at php and would like to have working code for myself to build upon, modify, and learn from. Any help is greatly appreciated!!!! Hey. Third question today. Very stuck on this one. I am displaying a ton of while loops to display a bunch of data from two different tables. there is NO possible way i can combine the two tables. I mean, I can, but I'm not going to because they are two totally different thins. Anyway. Here is what I'm trying to do: Lets say I have 3 items, a grape, an orange and an apple. - 3 apples - 2 oranges - 1 grape I'm displaying an update price box for each different fruit. (so 3 different boxes), and one submit button. I update it, and it does update the price but it only updates the very first row. I want to be able to update every row I types the price in for. Here is my code: (it is quite long): Code: [Select] <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>User Shops</font><br><br>"; $action = $_GET['action']; if(!isset($action)) { echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br>"; } if(isset($action)) { $getshopq = "SELECT * FROM usershops WHERE owner='$showusername'"; $getshop = mysql_query($getshopq); while($tri = mysql_fetch_array($getshop)) { $theid = $tri['ushopid']; $owner = $tri ['owner']; $desc = $tri['description']; $image = $tri['image']; $name = $tri['name']; $status = $tri['status']; $discount = $tri['discount']; } $countq = "SELECT * FROM usershops WHERE owner='$showusername'"; $countit = mysql_query($countq); if($action == "edit") { echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Edit Shop</font><br><br>"; if(mysql_num_rows($countit)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <?php } if(!mysql_num_rows($countit)) { $create = $_POST['create']; $thename = $_POST['thename']; $thedesc = $_POST['thedesc']; $thestatus = $_POST['thestatus']; $theimage = $_POST['theimage']; if(!isset($create)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Shop Name: <input type="text" name="thename"><br>Description<br><textarea name="thedesc" rows="5" cols="25"></textarea><br> Status: <select name="thestatus"> <option>Open</option> <option>Closed</option> <option>Gallery</option> </select><br><br> <input type="submit" name="create" value="Create Shop"></form> <?php } if(isset($create)) { if($thename == "" || $thedesc == "") { echo "<font color=red>Error! Please fill out the entire form!</font><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Shop Name: <input type="text" name="thename"><br>Description<br><textarea name="thedesc" rows="5" cols="25"></textarea><br> Status: <select name="thestatus"> <option>Open</option> <option>Closed</option> <option>Gallery</option> </select><br><br> <input type="submit" name="create" value="Create Shop"></form> <?php } if($thename != "" && $thedesc != "") { mysql_query("INSERT INTO usershops (owner, name, description, image, status, discount) VALUES ('$showusername', '$thename', '$thedesc', 'image.gif', '$thestatus', 'None')"); echo "<font color=green>Success! You have created your shop! Click <a href=?action=view>here</a> to view it.</font><br><br>"; } } } } if($action == "view") { echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Shop Name Here</font><br><br>"; $wowq = "SELECT * FROM uitems WHERE username='$showusername' AND location='2'"; $wow = mysql_query($wowq); while($wrow = mysql_fetch_array($wow)) { $umid = $wrow['uitemid']; $umiid = $wrow['theitemid']; $umloc = $wrow['location']; $umprice = $wrow['price']; $infoq = "SELECT * FROM items WHERE itemid='$umiid'"; $info = mysql_query($infoq); while($row = mysql_fetch_array($info)) { $myname = $row['name']; $myid = $row['itemid']; $myimage = $row['image']; $mydesc = $ow['description']; $myrarity = $row['rarity']; echo "$myname"; } } } if($action == "stock") { $setprice = $_POST['price']; $updateprice = $_POST['updateprice']; echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Stock Shop</font><br><br>"; $eq = "SELECT * FROM uitems WHERE username='$showusername' AND location='2' GROUP BY theitemid"; $ee = mysql_query($eq); while($erow = mysql_fetch_array($ee)) { $eeloc = $erow['location']; $eeid = $erow['theitemid']; $eenowid = $erow['uitemid']; $eeprice = $erow['price']; $wq = "SELECT * FROM items WHERE itemid='$eeid'"; $ww = mysql_query($wq); while($wrow = mysql_fetch_array($ww)) { $cq = mysql_query("SELECT * FROM uitems WHERE username='$showusername' AND location='2' AND theitemid='$eeid'"); $lcq = mysql_num_rows($cq); $fid = $wrow['itemid']; $fname = $wrow['name']; $fimage = $wrow['image']; $frarity = $wrow['rarity']; $fdesc = $wrow['description']; echo "$fname<br><img src=/images/items/$fimage>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="text" name="price" maxlength="5"><br><br> <?php } } if(isset($updateprice)) { mysql_query("UPDATE uitems SET price='$setprice' WHERE username='$showusername' AND theitemid='$fid'"); echo "<font color=green>Success! Your prices have been set and updated!</font>"; } ?> <input type="submit" name="updateprice" value="Update Prices"> <br> <?php } if($action == "quick") { echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Quick Stock</font><br><br>"; } } } ?> </html> To help you find it, I'm asking about the "stock" $_GET part, about three quarters down. Thanks in advance for anybody who can help me, I've been stuck on this script all day! Thanks again! Here is a link to the website I am designing. http://173.167.65.189/singleton/ the username and password is ksingleton at the bottom where the calendar is the query is searching for scheduled events, i am only posting the company_id right now, the problem I am having is I want a scheduled event that continues through the week to stay in line with the one before. But if the schedule before ended and a new one continues it moves the next date company_id up. How can i align the table rows or create an empty table row on all other days if there was a schedule before. here is the code for the calendar. Quote <?php $db = new mysqli(); $setdate=strtotime($_GET['date']); $session=$_GET['session']; $calview=$_GET['calview']; if ($setdate <> "") { $date=$setdate; } else { $date=time(); } $day=date('d',$date); $month=date('m',$date); $year=date('Y',$date); $first_day=mktime(0,0,0,$month,1,$year); $title=date('F',$first_day); $day_of_week = date('D', $first_day); switch($day_of_week) { case "Sun": $blank = 0;break; case "Mon": $blank = 1;break; case "Tue": $blank = 2;break; case "Wed": $blank = 3;break; case "Thu": $blank = 4;break; case "Fri": $blank = 5;break; case "Sat": $blank = 6;break; } $days_in_month = cal_days_in_month(0, $month, $year); echo "<table cellpadding=0 cellspacing=0 border=0>"; echo "<tbody>"; echo "<tr>"; echo "<td><a href=?session=$session&calview=day>Day</a></td>"; echo "<td><a href=?session=$session&calview=week>Week</a></td>"; echo "<td><a href=?session=$session&calview=month>Month</a></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=3>"; if ($calview=="month") { echo "<table border=1 width=800>"; echo "<tbody>"; echo "<tr height=25><th colspan=7> $title $year </th></tr>"; echo "<tr height=25><td width=58 align=center>Sunday</td><td width=58 align=center>Monday</td><td width=58 align=center>Tuesday</td><td width=58 align=center>Wednesday</td><td width=58 align=center>Thursday</td><td width=58 align=center>Friday</td><td width=58 align=center>Saturday</td></tr>"; $day_count = 1; echo "<tr height=50>"; while ( $blank > 0 ) { echo "<td></td>"; $blank = $blank-1; $day_count++; } $day_num = 1; while ($day_num <= $days_in_month ) { $newdate = $month ."/". $day_num ."/". $year; $msqlnewdate = date('m/d/Y',strtotime($newdate)); echo "<td valign=top><table cellpadding=0 cellspacing=0 border=0><tr><td><a href=?session=$session&calview=day&date=$newdate> $day_num </a></td></tr>"; $db = new mysqli('localhost','username','password', 'rsdata'); if (!$db) { echo 'ERROR: Could not connect to database.'; } else { $query = $db->query("SELECT * FROM rentals WHERE date_format(str_to_date(pdate_out,'%Y-%m-%d'), '%m/%d/%Y') <= '$msqlnewdate' AND date_format(str_to_date(pdate_in, '%Y-%m-%d'), '%m/%d/%Y') >= '$msqlnewdate'"); if ($query) { while ($result = $query->fetch_object()) { echo "<tr><td>".$result->company_id."</td></tr>"; } } echo "</table>"; } $day_num++; $day_count++; if ($day_count > 7) { echo "</tr><tr>"; $day_count=1; } } while ($day_count >1 && $day_count <=7 ) { echo "<td></td>"; $day_count++; } echo "</tr></table>"; } else if ($calview=="week") { } else { } echo "</td>"; echo "</tr>"; echo "</tbody>"; echo "</table>"; ?> MOD EDIT: DB credentials edited out. |