
cpharry
Members-
Posts
35 -
Joined
-
Last visited
Never
Everything posted by cpharry
-
Hi, I have got everything working except one thing. When the query that i run returns with a H i want it to change the echoed H's colour to red and the other option which is an A if that is returned echo it green. <?php $ally = str_replace("H","<p color= #FF0000 >H</p>",$row['ally']); $ally = str_replace("A","<p color='green'>A</p>",$row['ally']); echo $ally; ?> This is what i have alread but it isnt working. Any help appriciated.
-
How do i split up the search results from the different tables because if i have two results both with the id 1 when the user clicks on the link which uses the id to get the data from the table it will get confused, so how do i split the results up into say an echoed table for the different tabled results if that makes sense. Character Result Table ---------------------------- Character result id 1 Location Result Table --------------------------- Location result id 1 And currently whenever i search for something the entire two tables just echo all the data in them from the name column not what i searched for. <? $search = $_POST["search"]; $connection = mysql_connect("localhost","wowbasec","PASSWORD REMOVED"); mysql_select_db("wowbasec_class", $connection); $query = "select * from characters, location WHERE characters.name='$search' or location.name='$search' "; $result = mysql_query($query, $connection); if (!$result) { echo 'Invalid query: ' . mysql_error(). "<br>"; echo 'SQL Query: ' . $query. "<br>"; die(); } while ($r = mysql_fetch_assoc($result)) { // Begin while $ts = $r["name"]; ?> <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><a href="view.php?id=<?php echo $r['id'];?>"> <? echo $r['name'] ?></td> </tr> </table> <? } ?>
-
Just realised that if i put the 'name' like that instead of just name it doesnt give any errors but it also doesnt give any results which there are two.
-
This is the code now... <? $search = $_POST["search"]; $db = "`char`"; $connection = mysql_connect("localhost","wowbasec","PASSWORD REMOVED"); mysql_select_db("wowbasec_class", $connection); $query = "select * from `char`, location WHERE name='$search'"; $result = mysql_query($query, $connection); if (!$result) { echo 'Invalid query: ' . mysql_error(). "<br>"; echo 'SQL Query: ' . $query. "<br>"; die(); } while ($r = mysql_fetch_assoc($result)) { // Begin while $ts = $r["name"]; $ts1 = $r["id"]; ?> <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><a href="viewchar.php?id=<?php echo $ts1['id']; $ts1 = $_POST['id']; ?>"> <? echo $ts ?></td> </tr> </table> <? } ?> But i get this... Invalid query: Column 'name' in where clause is ambiguous SQL Query: select * from `char`, location WHERE name='harry'
-
<? $search = $_POST["search"]; $db = "`char`"; $connection = mysql_connect("localhost","wowbasec","PASSWORD REMOVED"); mysql_select_db("wowbasec_class", $connection); $query = "select * from `char`, location WHERE name='$search'"; $result = mysql_db_query("wowbasec_class", $query); while ($r = mysql_fetch_assoc($result)) { // Begin while $ts = $r["name"]; $ts1 = $r["id"]; ?> <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><a href="viewchar.php?id=<?php echo $ts1['id']; $ts1 = $_POST['id']; ?>"> <? echo $ts ?></td> </tr> </table> <? } ?>
-
Hi, I have a search form, i need it to search upto 4 different tables in the same database for whatever the person is searching for. At current whenever i put the tables like `char`, location its comes up with.... Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/wowbasec/public_html/search.php on line 13 I need some help if anyone can do that Thanks
-
Thanks working now will change the db name too thanks
-
What i want is i want to display... #Locations #Characters etc. But whenever i put in $result2 = mysql_query("SELECT * FROM char"); $rows2 = mysql_num_rows($result2); Extra i get this error... Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wowbasec/public_html/index.php on line 10
-
Hi, As youve probably notice im not that good with php however i know a bit. mysql_select_db("wowbasec_class", $connection); $result = mysql_query("SELECT * FROM location"); $result1 = mysql_query("SELECT * FROM char"); $rows = mysql_num_rows($result); I have this at the moment but if i want to put in another count for another table in the same database how do i do that without any errors?
-
Does anyone know what that error message means? Its know inserting the information but gives that error.
-
rckehoe when i changed to what you put i get the error. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
-
Nope still same error rckehoe.
-
Hey everyone, I have a form that goes to a processing page, there is a drop down menu on the form that gets locations from a database. The code for the form page is first and then process page. <? // Connect database mysql_connect("localhost","USERNAME TAKEN OUT","PASSWORD TAKEN OUT"); mysql_select_db("wowbasec_class"); // If submitted, check the value of "select". If its not blank value, get the value and put it into $select. if(isset($select)&&$select!=""){ $select=$_GET['select']; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <table width="70" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#00FFFF"> <tr> <td height="34"><div align="center">Character Add Page </div></td> </tr> <tr> <td height="208"><form action="addcharfile.php" method="post" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="191"><div align="right">Name:</div></td> <td width="309"><input name="name" type="text" id="name"></td> </tr> <tr> <td><div align="right">Location:</div></td> <td><select name="location" id="location"> <option value="">--- Select ---</option> <? // Get records from database (table "name_list"). $list=mysql_query("select * from location order by id asc"); // Show records by while loop. while($row_list=mysql_fetch_assoc($list)){ ?> <option value="<? echo $row_list['id']; ?>" <? if($row_list['id']==$select){ echo "selected"; } ?>><? echo $row_list['name']; ?></option> </select> </td> </tr> <tr> <td><div align="right">Health:</div></td> <td><input name="health" type="text" id="health"></td> </tr> <tr> <td><div align="right">Mana:</div></td> <td><input name="mana" type="text" id="mana"></td> </tr> <tr> <td><div align="right">Notes:</div></td> <td><textarea name="notes" id="notes"></textarea></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Add"> </div></td> </tr> </table> </form> </td> </tr> <tr> <td> </td> </tr> </table> </body> </html> <? // End while loop. } ?> <? $connection = mysql_connect("localhost","USERNAME TAKEN OUT","PASSWORD TAKEN OUT"); mysql_select_db("wowbasec_class", $connection); // Get values from form. $name=$_POST['name']; $location=$_POST['location']; $health=$_POST['health']; $mana=$_POST['mana']; $notes=$_POST['notes']; // Insert all parameters into database. // The id field is auto increment. You don't have to insert any value $sql = mysql_query("insert into char(name, location, health, mana, notes) values('$name', '$location', '$health', '$mana', '$notes')"); if (!mysql_query($sql,$connection)) { die('Error: ' . mysql_error()); } echo "1 record added"; // Close database connection mysql_close(); ?> Any help is apreciated, Thanks.
-
Thanks everyone i have solved the problem thanks to the posts here. After looking carfully a spark lit in my head Thanks once more.
-
No still get the from thing saying [email protected] There has to be a way that i can make that change from that into WoW Base.
-
Before i start i have go not much php knowledge so dont give it to me in jargon that i wont understand. Basically i have setup a script that when the user puts there email in its send an email to me stating the email as the title and another email to the person saying that we have recieved it. The problem i have is that the email a new person gets automatically goes in their junk box and the sender is [email protected] Now thats rubbish and i dont want it to be that i want it to be [email protected] Heres the code for the process page im using. <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $to = $_REQUEST['email'] ; $subject = "WoW Base"; $body = " Hello,\n We have recieved your email. As soon as we have a precise date for opening we will email it to you.\n After we fully open you will recieve a monthly newsletter. If you dont wish to recieve it then please reply to this email stating that.\n WoW Base\n"; mail( "$email", "WoW Base Email Notification", "$body", "$email" ); mail( "[email protected]", "Newsletter & Opening Email", $message, "From: $email" ); header( "Location: http://www.wow-base.co.uk/" ); ?> www.wow-base.co.uk Thats the site its all working but not right as i have said at the top. Thanks to any that can help.
-
Thats what I have so far but where would I put the count ? <?php $host="localhost"; // Host name $username="simnetwo"; // Mysql username $password="Taken OUT"; // Mysql password $db_name="simnetwo_test"; // Database name $tbl_name="posts"; // 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"); $ID=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE ForumID='$ID'"; $result=mysql_query($sql); $sql2="SELECT * FROM posts WHERE ForumID='$ID'"; $result2=mysql_query($sql2); ?> <body> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topics</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"> </td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row $postidid = $rows['ID']; ?> <tr> <td bgcolor="#FFFFFF"><a href="view_post.php?id= <? echo $rows['ID']; ?>"> <? echo $rows['Topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['ViewCount']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo mysql_num_rows($result3); ?></td> <td align="center" bgcolor="#FFFFFF"> </td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td align="right" bgcolor="#E6E6E6"> </td> <td align="right" bgcolor="#E6E6E6"> </td> <td align="right" bgcolor="#E6E6E6"> </td> <td align="right" bgcolor="#E6E6E6"> </td> </tr> </table> </body> </html>
-
Shall I post the page that I am working on and then you will knoe what I mean, I now that I can count it but I cant seem to word it because the count that I am using at the moment is under the main query block.
-
Hi, I have a forum project coming along and I need to make the replies variable that comes up next to the post on the forum view when you can see them all. However I can get it to work so that when a user posts a message then it adds 1 to the "replycount field" but what I cant get is that if I take it out it wont count the number of replies. I know roughly that it has to query the number of records found using the postid from both tables but I cant think of where to put it. Can anyone help.
-
Hi, This is the last major thing that I need help on. Basically I need certain rows of records to come out in a different coloured table row. If that makes sense I want "category rows" to come out a different colour to the way they are coming out now. I have thought this up... <?php if($parentsid='1'){ echo "class='body1'"; }else{echo "class='body2'";}?> But that doesnt work as you can see in the picture above. All help will be greatly appreciated.
-
I have uploaded the new files to the net and it all works, displaying all the forums with the ParentID of 1. What I want to do now is the following.. ---------------------- } CATEGORY NAME } Would obviously like this to ---------------------- } be looped so that it continues. RELEVANT FORUM } Is this possible ? The layout of the table would be how it would come out on the page; what I thought was that I could have a field where it has either a 0 or 1. 0 = Category 1 = Forum Just how do I do that code wise.
-
Here is the updated code. <?php $host="localhost"; // Host name $username="simnetwo"; // Mysql username $password="Sorry, cant put it in."; // Mysql password $db_name="simnetwo_test"; // Database name $tbl_name="forum"; // 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"); $sql= "SElECT * FROM `forum` WHERE ParentID='1'"; $result=mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ ?> <body> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="53%" align="center" bgcolor="#E6E6E6"><div align="left"><a href="view_forum.php?id=<? echo $row['ID']; ?>"><? echo $row['Name']; ?></a></div></td> <td width="15%" align="center" bgcolor="#E6E6E6"> </td> <td width="13%" align="center" bgcolor="#E6E6E6"> </td> <td width="13%" align="center" bgcolor="#E6E6E6"> </td> </tr> <tr> <td bgcolor="#FFFFFF"><BR></td> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"> </td> </tr> <?php } mysql_close(); ?> <tr> <td align="right" bgcolor="#E6E6E6"> </td> <td align="right" bgcolor="#E6E6E6"> </td> <td align="right" bgcolor="#E6E6E6"> </td> <td align="right" bgcolor="#E6E6E6"> </td> </tr> </table> </body> </html>
-
Ok, I got everything working except for I need it to list the categories for example. Categories - Bold Then the forums related to that under, not sure how to though. The present code dont allow that. If I have them in the database the way that I want them, I mean the order of them. How do I get it so that the categories with a ParentID of 0 to be bold and the other to be normal. Any suggestions ?
-
I had xampp on my of.
-
Done and natta, I will upload it to the web server and see what happens.