cragga_lfc
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Security Breach / Issuesthank you so much those links have put my mind at rest and have implemented the suggested advice
thanks for your response
Forum: Themes and Templates
In reply to: Paginate Results from SQL Queryhi for anyone who can help i have built a little more and getting somewhere on page
you will see i can get a list but:
– pagenitation not quite working
– and i can’t retrieve the data from the sql databaseany help would be great
[insert_php]$servername = "db567706584.db.1and1.com";$username = "dbo567706584";$password = "Nico_1983!";$dbname = "db567706584"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } global $wpdb; $myrows = $wpdb->get_results( "SELECT * FROM <code>Properties</code>,<code>Available</code> WHERE <code>Property Available Flag</code> = <code>Flag</code> ORDER BY <code>Property Number</code>", OBJECT); if ($myrows) { foreach ( $myrows as $property ) { echo "<table width='100%' align='center' border='3px solid grey'>"; echo"<tr>"; echo"<th>Picture</th>"; echo "<th>Details</th>"; echo "<th>More Info</th>"; echo "</tr>"; echo "<tbody>"; echo "<tr>"; echo "<td>Property Thumbnail URL</td>"; echo "<td>Property Title4HTML</td>"; echo "<td>Image Tag</td>"; echo "</tr>"; echo "</tbody>"; } echo "</table>"; } global $wp_query; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages ) ); // Test the use of paginate_links $rows_per_page = 7; $current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1; // $rows is the array that we are going to paginate. $rows = $wpdb->get_results("SELECT * FROM <code>Properties</code>,<code>Available</code> WHERE <code>Property Available Flag</code> = <code>Flag</code> ORDER BY <code>Property Number</code>"); global $wp_rewrite; $pagination_args = array( 'base' => @add_query_arg('paged','%#%'), 'format' => '', 'total' => ceil(sizeof($rows)/$rows_per_page), 'current' => $current, 'show_all' => false, 'type' => 'plain', ); if( $wp_rewrite->using_permalinks() ) $pagination_args['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . 'page/%#%/', 'paged'); if( !empty($wp_query->query_vars['s']) ) $pagination_args['add_args'] = array('s'=>get_query_var('s')); echo paginate_links($pagination_args); $start = ($current - 1) * $rows_per_page; $end = $start + $rows_per_page; $end = (sizeof($rows) < $end) ? sizeof($rows) : $end; echo '<br />'; for ($i=$start;$i < $end ;++$i ) { $property = $rows[$i]; echo "I:$i ID:{$row->ID} Title:{$row->post_title} <br />"; } [/insert_php]
Forum: Themes and Templates
In reply to: Paginate Results from SQL QueryHi i have followed a few help topics on here and generated the following code
but get this error:
Parse error: syntax error, unexpected end of file in /homepages/46/d567671028/htdocs/clickandbuilds/WordPress/LuxorEstates/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 81
here is my code – any help appreciated
[insert_php]$servername = ".........";$username = "........";$password = "........";$dbname = ".........."; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT <code>Property Thumbnail URL</code>,<code>Property Title4HTML</code>,<code>Image Tag</code> FROM <code>Properties</code>,<code>Available</code> WHERE <code>Property Available Flag</code> = <code>Flag</code> ORDER BY <code>Property Number</code>"; if ($myrows) { foreach ( $myrows as $property ) { $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr> <td>" . $row['Property Thumbnail URL'] . "</td><td>" . $row['Property Title4HTML'] . "</td><td>" . $row['Image Tag'] . "</td> </tr>"; } } else { echo "0 results"; } $conn->close(); //this is the counting number of page global $sql; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $sql->max_num_pages ) ); // Test the use of paginate_links $rows_per_page = 7; $current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1; // $rows is the array that we are going to paginate. $rows = $wpdb->get_results("SELECT <code>Property Thumbnail URL</code>,<code>Property Title4HTML</code>,<code>Image Tag</code> FROM <code>Properties</code>,<code>Available</code> WHERE <code>Property Available Flag</code> = <code>Flag</code> ORDER BY <code>Property Number</code>"); global $wp_rewrite; $pagination_args = array( 'base' => @add_query_arg('paged','%#%'), 'format' => '', 'total' => ceil(sizeof($rows)/$rows_per_page), 'current' => $current, 'show_all' => false, 'type' => 'plain', ); if( $wp_rewrite->using_permalinks() ) $pagination_args['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . 'page/%#%/', 'paged'); if( !empty($wp_query->query_vars['s']) ) $pagination_args['add_args'] = array('s'=>get_query_var('s')); echo paginate_links($pagination_args); $start = ($current - 1) * $rows_per_page; $end = $start + $rows_per_page; $end = (sizeof($rows) < $end) ? sizeof($rows) : $end; echo '<br />'; for ($i=$start;$i < $end ;++$i ) { $property = $rows[$i]; echo "I:$i ID:{$row->ID} Title:{$row->post_title} <br />"; } [/insert_php]
This is the link i am trying to use
“<a href=”
https://www.luxor-estates.com/our-properties/click-through/
“?PropRef=0003″>”
i think this is resolved – seems to have worked a treat on my pages adding the CSS
i think i have resolved it
i needed to add
td {
vertical-align: top;
}to the custom CSS plugin and the text when to the top
by all means tell me if this is wrong and wont work on other pages but it seems to have worked
beginners look if so
this is where i got the info:
https://stackoverflow.com/questions/2659508/html-align-table-rows-on-topHi Will i did it!!!
I got data back into a table
i was “echoing” the field titles and not the fields from the db – dhuur!!
so i amend to:
while($row = $result->fetch_assoc()) {
echo “<tr><td>” . $row[‘Property Thumbnail URL’] . “</td><td>” . $row[‘Property Title4HTML’] . “</td><td>” . $row[‘Image Tag’] . “</td></tr>”;
}now the results appear – but they don’t seem to be in a nice format – the text is aligned at the bottom
do you have any ideas how i can format this table now to look nice?!
thank you for your help was great to resolve it – just the formatting i can’t seem to figure out.
any ideas? would be greatly appreciated
tried something different from my search on google:
// output data of each row
while($row = $result->fetch_assoc()) {
echo “<tr><td>” . $row[‘Property Image’] . “</td><td>” . $row[‘Property Description’] . “</td><td>” . $row[‘Property Availability’] . “</td></tr>”;
}
} else {
echo “0 results”;
}
$conn->close();– but still no results show
apologies the fields and tables are not showing with the “`” i added at the beginning and the end of each field
Hi Will
i fixed the 0 results as my SQL script was wrong – i amended it to the following which means the “0 results” no longer appears
SELECT
Property Thumbnail URL
,Property Title4HTML
,Image Tag
FROMProperties
,Available
WHEREProperty Available Flag
=Flag
ANDProperty Available Flag
= ‘2’HOWEVER, i get no results showing now in a table
do you have any ideas?
thanks Craig
thank you Will
i have read the whole page and i think i have fixed the problem – however no parse issues appear
i get 0 results returned so it makes me think the script is wrong, but when i copy the script in phpMyAdmin it works
i dont know where to turn to now
the page – https://luxor-lettings.com/results-2/
here is my code:
<html>
<head>
<title>Available Properties</title>
</head>
<body>
<table>
<thead>
<tr>
<td>Property Image</td>
<td>Property Description</td>
<td>Property Availability</td>
</tr>
</thead>
<tbody>
[insert_php]
$servername = “db567706584.db.1and1.com”;
$username = “username”;
$password = “password”;
$dbname = “db567706584”;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}
$sql = “SELECT Property Thumbnail URL,Property Title4HTML,Image Tag FROM Properties,Available WHERE Property Available Flag = Flag AND Property Available Flag = ‘2’”;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo ‘<tr>’;
echo ‘<td>’;
echo $row[‘Property Image’];
echo ‘</td>’;
echo ‘<td>’;
echo $row[‘Property Description’];
echo ‘</td>’;
echo ‘<td>’;
echo $row[‘Property Availability’];
echo ‘</td>’;
echo ‘</tr>’;
}
} else {
echo “0 results”;
}
$conn->close();
[/insert_php]
</tbody>
</table>
</body>
</html>any help Will would be greatly appreciated as i truly am thankful for your help so far as i feel i am so close
thank you
Hi Will
thank you so much for helping me out i really appreciate it as i have been pulling my hair out for the last 3 days.
it has made changes to the errors now but no results still appear.
the error message i get now is:
Parse error: syntax error, unexpected ‘echo’ (T_ECHO), expecting ‘,’ or ‘;’ in /homepages/46/d567671028/htdocs/clickandbuilds/WordPress/LuxorEstates/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 23
the displayed results are on:
https://luxor-lettings.com/results-2/any help on this would be great. thank you
Forum: Plugins
In reply to: SQL Output in a tablesorry this is the page to see the results