Jump to content

cmgmyr

Members
  • Posts

    1,278
  • Joined

  • Last visited

    Never

Everything posted by cmgmyr

  1. did you see the "Please wait..." when you clicked on delete or no? try echoing the $id before you delete it to make sure it is getting passed through to the function.
  2. you might have to verify that your password is still the same now as when you first installed mysql, you might need to reset it.
  3. those globals were from my own script. you will have to make the DB connection. Yes this is the processor form. You will have to make the actual html form with the subject and message and whatever else you want. this will atleast get you started.
  4. how are you trying to connect? through the command line, or php?
  5. unless they have javascript disabled...
  6. did you make sure to make the connection to the database in both functions?
  7. true, thanks for that though. eventually i might want to make a "framework" where I would need that, but right now I just need MySQL
  8. Here, try this: index.php <?php function list_jokes(){ // Request the text of all the jokes $result = mysql_query("SELECT id, joketext FROM joke"); if (!$result) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } // Display the text of each joke in a paragraph while ($row = mysql_fetch_array($result)) { echo "<p>". $row['joketext'] . "<a href=\"index.php?action=delete_joke&id=".$row[id]."\"> Delete This Not Funny Joke</a>)</p>"; } } function delete_joke($id){ $id = $_GET['id']; $result = mysql_query("DELETE FROM joke WHERE id = $id"); echo "Joke Deleted!<br /><br />"; echo "<br />Please wait...<br /><br />"; echo "<META HTTP-EQUIV=Refresh CONTENT=\"2; URL=index.php\">"; } switch ($action){ case "list_jokes": list_jokes(); break; case "delete_joke": delete_joke($id) break; default: list_jokes(); Break; } ?>
  9. You can set it up as a switch if you want. That would get it into one file.
  10. yeah...you shouldn't really go for windows unless your application requires it. and usually if you are using php you can get away with just about anything on a linux box.
  11. I think you are going about things a little wrong. First make a page to display all of the jokes. (jokes.php) then make a page to delete a joke (delete.php). In joke.php you want a link from each record you output with the id in a link. (<a href="delete.php?id=$id">Delete Joke</a>) When you select that link it will now go to delete.php and delete that joke from the table, after it is deleted redirect the user back to jokes.php jokes.php <?php // Request the text of all the jokes $result = mysql_query("SELECT id, joketext FROM joke"); if (!$result) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } // Display the text of each joke in a paragraph while ($row = mysql_fetch_array($result)) { echo "<p>". $row['joketext'] . "<a href=\"delete.php?id=".$row[id]."\"> Delete This Not Funny Joke</a>)</p>"; } ?> delete.php <?php $id = $_GET['id']; $result = mysql_query("DELETE FROM joke WHERE id = $id"); echo "Joke Deleted!<br /><br />"; echo "<br />Please wait...<br /><br />"; echo "<META HTTP-EQUIV=Refresh CONTENT=\"2; URL=jokes.php\">"; ?> obviously you will need a little more then just that, but this is just the basics that you need. hope this helps.
  12. cmgmyr

    How to make?

    You can do something like: <input type="submit" name="submit" value="Edit Profile" /> <input type="submit" name="submit" value="Preview Profile" /> to: if($_POST['submit'] == 'Edit Profile'){ //edit profile }else{ //preview profile }
  13. It would work kinda like your page counter: link on page: <a href="fav.php?page=$page">I like it!</a> and your fav.php: <?php // Page ID $page = $_GET['page']; require("connect.php"); $result = mysql_query("SELECT fav_count FROM favs WHERE page_id = $page"); $t_count = mysql_num_rows($result); if($t_count > 0){ $cnt = mysql_result($result, 0, 'fav_count'); $cnt++; mysql_query("UPDATE favs SET fav_count = $cnt WHERE page_id = $page"); }else{ mysql_query("INSERT INTO favs ( page_id , fav_count ) VALUES ($page, '1')"); } echo "Thank you for telling us you like this!<br />Please wait..."; echo "<META HTTP-EQUIV=Refresh CONTENT=\"2; URL=$page.php\">"; ?> You can use the same DB structure that I sent to you before...just change the name of the table to "favs" and page_count to "fav_count"
  14. you might want to include all of the related files into one file, so it might be a little to manage...I don't know if you should do this in framework, but I would think it would be ok. For example: library.php <?php include "errors.php"; include "database.php"; include "forms.php"; ?> so now you can just call library.php if you need any one of those 3 pages.
  15. No problem, glad I could help. If you need to know anything else just set up a new post Welcome to the board!
  16. I'm glad we can help you out. We do not have a rating system anymore. We started with one when we converted over to this board (SMF) but some people abused it a little too much so the mods took it off. But most people in here know who's good and who's not. You'll know that too when you are around a little bit longer. Whenever you need something answered just post and you shall receive
  17. no problem, glad to help
  18. You can use something like this: $result = mysql_query("SELECT page_count FROM view WHERE page_id = $page"); $t_count = mysql_num_rows($result); if($t_count > 0){ $cnt = mysql_result($result, 0, 'page_count'); echo "Threre are $cnt page views."; }else{ echo "There are no page views."; }
  19. no problem, i got it thanks again for all the help! hopefully nothing else will come up.
  20. All you have to do is add a simple if statement...since you already have the number of rows from the query the work is already done for you. Take a look: <?php $host = "localhost"; $user = "test"; $pass = "test"; $dbname = "test"; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $postCode = $_REQUEST["postcode"]; $companyName = $_REQUEST["coname"]; $addre = $_REQUEST["address"]; $result = mysql_query("SELECT * FROM members WHERE companyname LIKE '%{$companyName}%' AND postcode LIKE '%{$postCode}%' AND address LIKE '%{$addre}%' LIMIT 1") or die(mysql_error()); $num = mysql_num_rows($result); if($num > 0){ $i = 0; while ($i < $num) { $membernumber = mysql_result($result,$i,"membernumber"); $companyname = mysql_result($result,$i,"companyname"); $address = mysql_result($result,$i,"address"); $postcode = mysql_result($result,$i,"postcode"); $phone = mysql_result($result,$i,"phone"); $email = mysql_result($result,$i,"emailaddress"); echo "<table>"; echo "<tr><th class='content'>Membership No:</th><td class='content'>$membernumber</td></tr>"; echo "<tr><th class='content'>Company Name:</th><td class='content'>$companyname</td></tr>"; echo "<tr><th class='content'>Address:</th><td class='content'>$address</td></tr>"; echo "<tr><th class='content'>Phone:</th><td class='content'>$phone</td></tr>"; echo "<tr><th class='content'>Postcode:</th><td class='content'>$postcode</td></tr>"; echo "</table>"; $i++; } }else{ echo "We are sorry there are no records in the database."; } ?>
  21. <?php $i = 1; switch ($i) { case 0: echo " i equals 0"; break; case 1: echo " i equals 1"; break; case 2: echo " i equals 2"; break; } ?> echos "i equals 1"
  22. Try this: Drop the old table and use this one: CREATE TABLE `view` ( `page_id` int(11) NOT NULL default '0', `page_count` int(11) default NULL, PRIMARY KEY (`page_id`) ) ENGINE=MyISAM; And use this as your php: <?php // Page ID $page = 1; require("connect.php"); $result = mysql_query("SELECT page_count FROM view WHERE page_id = $page"); $t_count = mysql_num_rows($result); if($t_count > 0){ $cnt = mysql_result($result, 0, 'page_count'); $cnt++; mysql_query("UPDATE view SET page_count = $cnt WHERE page_id = $page"); }else{ mysql_query("INSERT INTO view ( page_id , page_count ) VALUES ($page, '1')"); $cnt = 1; } // echo the number of htis echo $cnt; ?> It worked for me
  23. It will usually always tell you the wrong line, because it gives you an error on where your problem "became" a problem...not where it started. So whenever you get an error like that you will have to backtrack a little. You always want to break up your statements because it looks better and is easier to read and as I said before if you add more then one line in the statement you will have to use them anyways. But you should just use them because it is "good programming practice" So if you get into a habbit of using them now...you will always use them.
  24. Try this... Change: } $i++; to: $i++ }
  25. not a problem...i should have seen that earlier myself. The function was echoing the result instead of returning it to the top where it was called. Glad I could help!
×
×
  • 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.