Jump to content

view records // edit records display blank


careym1989

Recommended Posts

When I visit these pages using my own content management system, they both appear to be blank.

 

Here's the code for the view records page:

 

<?php

echo '<h1>VIEW CANDIDATES</h1>';

require_once('../mysqli_connect.php');

$q = "SELECT n, cc, st, ea, cd, url, approved FROM candidatesubmit ORDER BY id DESC";

$r = @mysqli_query ($dbc, $q);

$num = mysqli_num_rows($r);

if ($num > 0) {

echo 'There are currently $num candidate records. Some pending, some approved';

echo '<table align="center" cellspacing="3" cellpadding="3" width="100%">

<tr>
<td align="left"><b>Edit</b></td>
<td align="left"><b>Name</b></td>
<td align="left"><b>City County</b></td>
<td align="left"><b>State</b></td>
<td align="left"><b>Email</b></td>
<td align="left"><b>CurrentlyRunningorOfficeHeld</b></td>
<td align="left"><b>URL</b></td>
<td align="left"><b>approved?</b></td>
</tr>
';

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {

echo '<tr>

<td align="left"><a href="ff_Edit.php?id=' . $row['id'] . '">Edit</a></td>
<td align="left">' . $row['n'] . '</td>
<td align="left">' . $row['cc'] . '</td>
<td align="left">' . $row['st'] . '</td>
<td align="left">' . $row['ea'] . '</td>
<td align="left">' . $row['cd'] . '</td>
<td align="left">' . $row['url'] . '</td>
<td align="left">' . $row['approved'] . '</td>

</tr>

';

}

echo '</table>';

mysqli_free_result ($r);

} else { 

echo 'There are no registered users';

}

mysqli_close($dbc);

?>

 

And here's the code for edit record:

 

<?php

echo '<h1>Edit a User</h1>';

if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) {

$id = $_GET['id'];

} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) {

$id = $_POST['id'];

} else {

echo 'This page has been accessed in error';

exit();

}

require_once('../mysqli_connect.php');

if (isset($_POST['submitted'])) {

$errors = array();

if (empty($_POST['n'])) {

$errors[] = 'You did not enter a name.';

} else { 

$n = mysqli_real_escape_string($dbc, trim($_POST['n']));

}

if (empty($_POST['cc'])) {

$errors[] = 'You did not enter a City or County.';

} else {

$cc = mysqli_real_escape_string($dbc, trim($_POST['cc']));

}

if (empty($_POST['st'])) {

$errors[] = 'You did not enter a State.';

} else {

$st = mysqli_real_escape_string($dbc, trim($_POST['st']));

}

if (empty($_POST['ea'])) {

$errors[] = 'You did not enter an email address.';

} else {

$ea = mysqli_real_escape_string($dbc, trim($_POST['ea']));

}

if (empty($_POST['cd'])) {

$errors[] = 'You did not enter an office seeking or currently held.';

} else {

$cd = mysqli_real_escape_string($dbc, trim($_POST['cd']));

}

if (empty($_POST['url'])) {

$errors[] = 'You did not enter a website.';

} else {

$url = mysqli_real_escape_string($dbc, trim($_POST['url']));

}

if (empty($errors)) {

$q = "SELECT id FROM candidatesubmit WHERE ea='$ea' AND id != $id";

$r = @mysqli_query($dbc, $q);

if (mysqli_num_rows($r) == 0) {

$q = "UPDATE candidatesubmit SET n='$n', cc='$cc', st='$st', ea='$ea', cd='$cd', url='$url', approved='$approved' WHERE id=$id LIMIT 1";

$r = @mysqli_query ($dbc, $q);

if (mysqli_affect_rows($dbc) == 1)
{

echo 'The record has been edited.';

} else {

echo 'The record could not be edited due to a system error. Try again in a couple of hours.';

}

} else {

echo 'The email address has already registered.';

}

} else {

echo 'The following errors occurred';

echo 'You messed up, Carey';

}

echo ' Please try again.';

}


$q = "SELECT n, cc, st, ea, cd, url, approved FROM candidatesubmit WHERE id=$id";

$r = @mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) {

$row = mysqli_fetch_array ($r, MYSQLI_NUM);

echo '<form action="edit_user.php" method="post">

Name <input type="text" name="n" value="' . $row[0] . '" />
<br>
City County Come from <input type="text" name="cc" value="' . $row[1] . '" />
<br>
State <input type="text" name="st" value="' . $row[2] . '" />
<br>
Email <input type="text" name="ea" value="' . $row[3] . '" />
<br>
Office held or currently running for <input type="text" name="cd" value="' . $row[4] . '" />
<br>
URL <input type="text" name="url" value="' . $row[5] . '" />
<br>
Approved? <input type="text" name="approved" value="' . $row[6] . '" />
<br>
<input type="submit" name="submit" value="Submit" />
<br>
<input type="hidden" name="submitted" value="TRUE" />
<br>
<input type="hidden" name="id" value="' . $id . '" />
</form>';

} else {

echo 'This page has been accessed in error.';

}

mysqli_close($dbc);

?>

 

Any help would be greatly appreciated.

 

Regards,

Carey

Link to comment
https://forums.phpfreaks.com/topic/124000-view-records-edit-records-display-blank/
Share on other sites

There should be no reason for it to be blank. Is it COMPLETELY blank, or do you at least see the text on the top of the page that says "VIEW CANDIDATES"?

 

Try adding this to the top of your script

error_reporting(E_ALL);

Maybe there is an error in your query for the view records script.

 

Try changing

$r = @mysqli_query ($dbc, $q);

 

To

$r = mysqli_query ($dbc, $q)or die(mysql_error());

 

I'm not familiar with using "mysqli", so hopefully the error function is the same. Also, is there a reason your suppressing errors with the @?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.