ryeman98 Posted June 29, 2007 Share Posted June 29, 2007 I don't get any errors or anything so I just don't get why it won't work. I'm connected to the database and the table that I have is there. It's supposed to display each Clothing item by a link... <?php // Display the list $query = mysql_query("SELECT * FROM CustomisationClothes ORDER BY name"); $result = mysql_fetch_array($query); echo "<a href\""; echo $sPHPSELF; echo "?edit="; echo $result['name']; echo "\">"; echo $result['name']; echo "</a>"; ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 29, 2007 Share Posted June 29, 2007 echo "<a href=".$sPHPSELF."?edit=".$result['name'].">text here</a>"; try that way Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 You can try this as well. <?php // Display the list $query = mysql_query("SELECT * FROM CustomisationClothes ORDER BY name"); $result = mysql_fetch_assoc($query)or die(mysql_error()); echo "<a href='$sPHPSELF?edit={$result['name']}'>{$result['name']}</a>"; ?> It's also a possibility that there is an error in your query and it isn't returning anything, so I tacked on the error checking. Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted June 30, 2007 Author Share Posted June 30, 2007 echo "<a href=".$sPHPSELF."?edit=".$result['name'].">text here</a>"; try that way I did and it didn't work :-\ Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 30, 2007 Share Posted June 30, 2007 echo "<a href=".$sPHPSELF."?edit=".$result['name'].">text here</a>"; sorry i misplace the</a> but that should work Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted June 30, 2007 Author Share Posted June 30, 2007 Neither way is working. I'm going to post the entire code. But, there is no errors at all. <?php $pagetitle = "........."; include($_ENV['SITE_HTMLROOT']."/header.php"); require($_ENV['SITE_HTMLROOT']."/include/dbconnect_class.php"); $db = new DB; $sPHPSELF = $_SERVER['PHP_SELF']; ?> <h1>Edit Clothing</h1> <?php if ($_GET['edit'] == $name) { $name = $_POST['name']; $edit = mysql_query("SELECT * FROM CustomisationClothes WHERE name='$name'"); while($row = mysql_fetch_array($edit)) { echo "<img src=\"".$row['img_url']."\" alt=\"".$row['name']."\" /> <form name=\"editClothes\" action=\"editClothing.php\" method=\"post\"> <b>Name:</b> <input type=\"text\" name=\"name\" value=\"".$row['name']."\" /><br /> <b>IMG URL:</b> <input type=\"text\" name=\"img_url\" value=\"".$row['img_url']."\" /><br />"; $acara = mysql_query("SELECT * FROM CustomisationClothes WHERE acara"); $aisha = mysql_query("SELECT * FROM CustomisationClothes WHERE aisha"); if ($acara == "yes") { echo "<input type='checkbox' name='acara' value='".$acara."' checked='checked' />"; } else { echo "<input type='checkbox' name='acara' value='".$acara."' />"; } if ($aisha == "yes") { echo "<input type='checkbox' name='aisha' value='".$aisha."' checked='checked' />"; } else { echo "<input type='checkbox' name='aisha' value='".$aisha."' />"; } ?> <input type="submit" name="submit" value="Edit Clothing" /> </form> <?php } // End while } else { // Display the list $query = mysql_query("SELECT * FROM CustomisationClothes ORDER BY name") or die(mysql_error()); $result = mysql_fetch_assoc($query) or die(mysql_error()); echo "<a href\"".$sPHPSELF."?edit=".$result['name']."\">".$result['name']."</a>"; } // End else ?> <?php include($_ENV['SITE_HTMLROOT']."/footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 30, 2007 Share Posted June 30, 2007 echo '<a href="?edit="'.$result['name'].'"> your text here </a>'; that should work you dont need the server thing basically when you do this on the href ?that means that it links to it self with the add stuf Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted June 30, 2007 Author Share Posted June 30, 2007 That doesn't really make a difference. It still doesn't work... :-\ Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 30, 2007 Share Posted June 30, 2007 tell me the prob :-\ Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 <?php $acara = mysql_query("SELECT * FROM CustomisationClothes WHERE acara"); $aisha = mysql_query("SELECT * FROM CustomisationClothes WHERE aisha"); ?> These two queries have nothing to do with your link not working, but they are both invalid. You need to be more specific on the conditon: WHERE aisha Where aisha...? Where aishia is what, or equal to what? Those queries will most likely bring up problems later on when your testing your script. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 The query that is effecting your links looks like this: $query = mysql_query("SELECT * FROM CustomisationClothes ORDER BY name") or die(mysql_error()); You have an ORDER BY in there...so your obviously wanting to display more than one result, correct? To do that you will need a while loop. Just for the sake of testing, try changing your query to this: $query = mysql_query("SELECT * FROM CustomisationClothes") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted June 30, 2007 Author Share Posted June 30, 2007 I know they don't have anything to do with it. The link that I'm working on is going to submit to the isset. I have a while loop now but still... no dice... Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 Okay, let me make sure I understand your problem. There is absolutely NO output from this: echo "<a href\"".$sPHPSELF."?edit=".$result['name']."\">".$result['name']."</a>"; It is displaying a total blank screen? See if you get something from replacing that with this: echo "<a href\"".$sPHPSELF."?edit=".$result['name']."\">TEST</a>"; Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted June 30, 2007 Author Share Posted June 30, 2007 Well it is displaying everything except for the links. Again... that didn't work. :-\ Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 Try this: <?php $pagetitle = "........."; include($_ENV['SITE_HTMLROOT']."/header.php"); require($_ENV['SITE_HTMLROOT']."/include/dbconnect_class.php"); $db = new DB; $sPHPSELF = $_SERVER['PHP_SELF']; ?> <h1>Edit Clothing</h1> <?php if ($_GET['edit'] == $name) { $name = $_POST['name']; $edit = mysql_query("SELECT * FROM CustomisationClothes WHERE name='$name'"); while ($row = mysql_fetch_array($edit)) { echo "<img src=\"".$row['img_url']."\" alt=\"".$row['name']."\" /> <form name=\"editClothes\" action=\"editClothing.php\" method=\"post\"> <b>Name:</b> <input type=\"text\" name=\"name\" value=\"".$row['name']."\" /><br /> <b>IMG URL:</b> <input type=\"text\" name=\"img_url\" value=\"".$row['img_url']."\" /><br />"; $acara = mysql_query("SELECT * FROM CustomisationClothes WHERE acara"); $aisha = mysql_query("SELECT * FROM CustomisationClothes WHERE aisha"); if ($acara == "yes") { echo "<input type='checkbox' name='acara' value='".$acara."' checked='checked' />"; } else { echo "<input type='checkbox' name='acara' value='".$acara."' />"; } if ($aisha == "yes") { echo "<input type='checkbox' name='aisha' value='".$aisha."' checked='checked' />"; } else { echo "<input type='checkbox' name='aisha' value='".$aisha."' />"; } ?> <input type="submit" name="submit" value="Edit Clothing" /> </form> <?php } // End while } // Display the list $query = mysql_query("SELECT * FROM CustomisationClothes ORDER BY name") or die(mysql_error()); $result = mysql_fetch_assoc($query) or die(mysql_error()); echo "<a href\"".$sPHPSELF."?edit=".$result['name']."\">".$result['name']."</a>"; ?> <?php include($_ENV['SITE_HTMLROOT']."/footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted June 30, 2007 Author Share Posted June 30, 2007 What did you change...? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 I didn't wrap the if statement around the part that should display the default page. Did it work? Quote Link to comment Share on other sites More sharing options...
JP128 Posted June 30, 2007 Share Posted June 30, 2007 echo "<a href='",$sPHPSELF,"?edit=",$result['name'],"'>",$result['name'],"</a>"; try that... you have been missing the = sign Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 Ah, I figured out the main problem though. All you have to do is remove change this line: if ($_GET['edit'] == $name) { To: if ($_GET['edit']) { The "== $name" part wouldn't even make sense there. You don't have that variable defined anywhere in the script before that line...so it has no idea what $name is. I would personally change the line to this: if (!empty(trim($_GET['edit']))) { With that change, the code should work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.