My below code is not fetching a single row from my table ,but the sql is fully functional

<?php
/**
 * Template Name:Form_print
 */
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->


<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
td
{
	border-top:1px solid #000000;
	border-right:1px solid #000000;
}
td
{
	border-top:1px solid #000000;
	border-right:1px solid #000000;
	padding:0px 10px 0px 0px;
}
table
{
	border-bottom:1px solid #000000;
	border-left:1px solid #000000;
}
</style>
<body>
<?php
$reg=$_GET['reg'];
global $wpdb;
$table_name = $wpdb->prefix . "apply_entry";
$retrieved_data = $wpdb->get_row( "SELECT * FROM $table_name where regid='$reg'" ); // this is the error line or idon't know to how to fech it 
?>
<div class="header">
<h1 style="color:#ff0505">Application Entries:</h1>

</div>
<div class="table">
<table border=1>
<tr class="danger"  colspan="1">
<td>Register Id</td>
<td>Name</td>
<td>Father/Husband Name</td>
<td>Email Id</td>
<td>Date of Birth</td>
<td>Address</td>
<td>Mobile No</td>
<td>Alternative Mobile No</td>
<td>Marital Status</td>
<td>Education Qualification</td>
<td>Preferred Job</td>
<td>preferred Location</td>
<td>Previous Company</td>
<td>Experience</td>
<td>Designation</td>
</tr>

<?php 
if($retrieved_data)
{ ?>
<tr class="active">
<td><?php echo $retrieved_data->regid;?></td>
<td><?php echo $retrieved_data->name;?></td>
<td><?php echo $retrieved_data->fhname;?></td>
<td><?php echo $retrieved_data->email;?></td>
<td><?php echo $retrieved_data->birth;?></td>
<td><?php echo $retrieved_data->addr;?></td>
<td><?php echo $retrieved_data->mobile;?></td>
<td><?php echo $retrieved_data->alternate;?></td>
<td><?php echo $retrieved_data->mstatus;?></td>
<td><?php echo $retrieved_data->qualification;?></td>
<td><?php echo $retrieved_data->p_job;?></td>
<td><?php echo $retrieved_data->p_location;?></td>
<td><?php echo $retrieved_data->com_name;?></td>
<td><?php echo $retrieved_data->work_exp;?></td>
<td><?php echo $retrieved_data->desg;?></td>
</tr>
<?php 
}
?>

</table>
<?php

?>
</div>
</body>
</html>
<script type="text/javascript">
window.print();
</script>
<script type="text/javascript">
window.location.assign('job_fair');
</script>
var_dump($retrieved_data);

ok I got the answer

Great, @karthikitmake. For the benefit of members who read this thread in the future, could you please explain briefly what you did to fix the problem?

I change this line

like this

$retrieved_data = $wpdb->get_row( $wpdb->prepare(“SELECT * FROM $table_name where regid=%d”,$reg));

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.