Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CMS for MySQL Database

Featured Replies

Okay basically I have set up 2 databases for a poker club, 'Tourney League' and 'Cash League'.

 

Each database displays a players rank (id) name & points.

 

I want to have a page that is dedicated to editing this database with a simple form that would potentially, ADD/DELETE & EDIT players within the database, It doesnt have to have much security as Its only a small club and I would only show the manager the specific page in which to edit the details.

 

Effectively I would like it so the ADD player option would add a new player into the database, the DELETE would remove them permenently and the EDIT would allow you to add points to a player which would add to his original figure.

 

Is this a simple thing to do? What Is the simple most efficient way I can do this In a short space of time then look to review it and improve it at a later date?

 

Any information or advice would be a great help, Thanks.

 

Will

 

EDIT: I understand you can use the UPDATE function to do this, how simple would it be to apply this in a form?

 

Could I possibly do something like this;

 

<?php
$con = mysql_connect("localhost","user","pw");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("my_db", $con);

mysql_query("UPDATE Points SET [figure from form here]
WHERE Name='Peter'");

mysql_close($con);
?>

Edited by Willows

First you would need to set up a table called admin, having fields in there like id,username,password,etc... and if you wanna actually control the entire site you may have to dig more in depth creating tables that can hold the sites title,tagline,date formatting etc.. then a table that may hold things like different pages. This is not a short process when you say CMS it basically means you want a way to edit the entire site or a portion of the site using an admin panel.And when your thinking of putting security on the back burner you may want to think about how the search engine may index your admin area , making it visible to quite a few people.

Edited by webdesigner93

  • Author

First you would need to set up a table called admin, having fields in there like id,username,password,etc... and if you wanna actually control the entire site you may have to dig more in depth creating tables that can hold the sites title,tagline,date formatting etc.. then a table that may hold things like different pages. This is not a short process when you say CMS it basically means you want a way to edit the entire site or a portion of the site using an admin panel.

 

The site its self is going to be controlled by me, but the manager of the poker club wants to easily just update the records. I figured a simple HTML/PHP form in which would just update the DB displaying the names and points would work easily for him, aslong as I can build a simple form that can do it, I can then think about adding an admin page so only specific users can access the page. Does this help? Just need help with coding something that links the form entrys to updating the database....

 

 

EDIT

 

"And when your thinking of putting security on the back burner you may want to think about how the search engine may index your admin area , making it visible to quite a few people."

 

I wouldnt put the site live untill i built the security part, i just want to accomplish the actual change of database first then work my way there.

Edited by Willows

  • Author

Sorry to bump but really need help with this, I have come up with this code so far through some help but i get an error code:

 

Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\tournementleagueupdate.php on line 20

 

But I dont understand the problem becuase there is no unexpected '<' on line 20?

 

<?php

$Name=$_GET['Name'];
$username="root";
$password="pw";
$database="CashLeague";
mysql_connect(localhost,$username,$password);

$query=" SELECT * FROM CashTable WHERE id='$Name'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$Name=mysql_result($result,$i,"Name");
$Points=mysql_result($result,$i,"Points");


<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo $id; ?>">
Name: <input type="text" name="ud_Name" value="<? echo $Name; ?>"><br>
Points: <input type="text" name="ud_Points" value="<? echo $Points; ?>"><br>
<input type="Submit" value="Update">
</form>

++$i;
}

?>

This should fix it

<?php

$Name=$_GET['Name'];
$username="root";
$password="pw";
$database="CashLeague";
mysql_connect(localhost,$username,$password);

$query=" SELECT * FROM CashTable WHERE id='$Name'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$Name=mysql_result($result,$i,"Name");
$Points=mysql_result($result,$i,"Points");
?>

<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo $id; ?>">
Name: <input type="text" name="ud_Name" value="<? echo $Name; ?>"><br>
Points: <input type="text" name="ud_Points" value="<? echo $Points; ?>"><br>
<input type="Submit" value="Update">
</form>

<?php
++$i;
}

?>

 

also this

mysql_numrows($result);

needs to be this

mysql_num_rows($result);

Edited by webdesigner93

  • Author

Changed the code,

 

<form method="post" action="submit.php">
 <input type="text" name="id" value="Points" />
 <input type="text" name="value" value="Name" />
 <input type="submit" />
</form>

<?php
$host = "localhost"; 
$user = "root"; 
$pass = "pw";
$database = "cashleague";
$conn = mysql_connect($host, $user, $pass) or die( mysql_error() );
       mysql_select_db($database) or die( mysql_error() );

print $_POST["id"]; 
print $_POST["value"]; 

$sql = "UPDATE CashTable SET value = '{$value}' WHERE id = {$id}";

?>

 

Do I change 'value' and 'id' to the specific columns i want changing in my DB? as I get an error code..

 

Notice: Undefined index: id in C:\xampp\htdocs\tournementleagueupdate.php on line 15

 

Notice: Undefined index: value in C:\xampp\htdocs\tournementleagueupdate.php on line 16

 

Notice: Undefined variable: value in C:\xampp\htdocs\tournementleagueupdate.php on line 18

 

Notice: Undefined variable: id in C:\xampp\htdocs\tournementleagueupdate.php on line 18

Edited by Willows

Mmm not to sound rude but you really should start researching things on google, its not hard to type in what ever error or problem your having and get a solution, its easier to learn if you do most the work yourself instead of having people give you snipplets of code on here

  • Author

Mmm not to sound rude but you really should start researching things on google, its not hard to type in what ever error or problem your having and get a solution, its easier to learn if you do most the work yourself instead of having people give you snipplets of code on here

 

 

Of course, I can understand where your coming from, just right now im working on a deadline and I have knowledge of MySQL whatsoever so im just tryna do as best as I can In the short time I've got then Im gunna teach myself and supply my knowledge back to forum and help guys like some have helped me over the last couple of days..

Of course, I can understand where your coming from, just right now im working on a deadline and I have knowledge of MySQL whatsoever so im just tryna do as best as I can In the short time I've got then Im gunna teach myself and supply my knowledge back to forum and help guys like some have helped me over the last couple of days..

aw i figured it was just a personal project not for a client or anything, but as a hint, your getting the undefined errors because your not checking if they are set before displaying any data, try writing your variables like this instead of like this print $_POST['id'];

 

 

$id = (isset($_POST['id'])) ? $_POST['id'] : false;

 

then echo them

 

echo $id;

  • Author

aw i figured it was just a personal project not for a client or anything, but as a hint, your getting the undefined errors because your not checking if they are set before displaying any data, try writing your variables like this instead of like this print $_POST['id'];

 

 

$id = (isset($_POST['id'])) ? $_POST['id'] : false;

 

then echo them

 

echo $id;

 

 

Thanks man, really helpful stuff, I've learnt so much in the last week just from this forum, Its incredible, thanks again.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.