Jump to content

cpharry

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cpharry's Achievements

Member

Member (2/5)

0

Reputation

  1. 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.
  2. 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> <? } ?>
  3. 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.
  4. 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'
  5. <? $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> <? } ?>
  6. 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
  7. Thanks working now will change the db name too thanks
  8. 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
  9. 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?
  10. Does anyone know what that error message means? Its know inserting the information but gives that error.
  11. 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
  12. Nope still same error rckehoe.
  13. 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.
  14. Thanks everyone i have solved the problem thanks to the posts here. After looking carfully a spark lit in my head Thanks once more.
  15. 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.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.