Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-17-2022, 10:39 PM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,184
Another quick if statement question & sql query

I'm trying to make a data entry from my database bold if it meets the 'yes' criteria in the 'sponsor' field.

I have this so far but, I can't seem to get it working, any help on where/what I am screwing up please?

Quote:
<?php if($statement=='IF(SELECT Name, IF(Sponsor='Yes')
FROM TABLE;){ echo "<strong>";}?>
The text HERE
<?php if($statement=='IF(SELECT Name, IF(Sponsor='Yes')
FROM TABLE;){ echo "</strong>";}?>
Is the above even a 'thing'?

I think I'm on the right track but screwing up calling the data and IF statement correcty?

The $conn is opened a little further up the page, and closed below where I want this bold text to appear.

OR as an alternative, should I just put <b></b> around the name in the SQL database and just use htmlspecialchars? Any potential issues with doing that?
__________________
Extreme Link List - v1.0
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-17-2022, 11:38 PM   #2
natkejs
Confirmed User
 
Industry Role:
Join Date: Jan 2003
Location: Nomad Land
Posts: 1,629
Quote:
Originally Posted by Publisher Bucks View Post
I'm trying to make a data entry from my database bold if it meets the 'yes' criteria in the 'sponsor' field.

I have this so far but, I can't seem to get it working, any help on where/what I am screwing up please?



Is the above even a 'thing'?

I think I'm on the right track but screwing up calling the data and IF statement correcty?

The $conn is opened a little further up the page, and closed below where I want this bold text to appear.

OR as an alternative, should I just put <b></b> around the name in the SQL database and just use htmlspecialchars? Any potential issues with doing that?
You are not calling your database at all.

How are you getting the results you are looping through?

You probably have the sponsor column in those results and can just verify against it.

PHP Code:
foreach ( $myResults as $row ) {
$string 'bla bla bla';
if ( 
$row['sponsor'] == 'yes' $string "<strong>$string</strong>";
echo 
$string;

__________________
natkejs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-18-2022, 12:36 AM   #3
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,184
Quote:
Originally Posted by natkejs View Post
You are not calling your database at all.
It gets opened at the top of the page:

Quote:
<?php

$id=intval($_GET['id']);

if($id==0)

{

header( "Location: ./404/" ); // 404 Ad Directory

exit;

}

$pdo=hookitup();

$table = "Directory";

$sql="select * from " . $table . " where ID=" . $pdo->quote($id);

//echo "sql=" . $sql . "<br>";

$stmt=$pdo->query($sql);

//echo "rows back=" . $stmt->rowcount() . "<br>";

$row=$stmt->fetch(PDO::FETCH_ASSOC);

$name = $row['Name'];
$street = $row['Street'];
$city = $row['City'];
$state = $row['State'];
$zip = $row['Zip'];
$phone = $row['Phone'];
$email = $row['Email'];
$website = $row['Website'];
$facebook = $row['Facebook'];
$twitter = $row['Twitter'];
$description = $row['Description'];
$category = $row['Category'];
$monday = $row['Monday'];
$tuesday = $row['Tuesday'];
$wednesday = $row['Wednesday'];
$thursday = $row['Thursday'];
$friday = $row['Friday'];
$saturday = $row['Saturday'];
$sunday = $row['Sunday'];
$sponsor = $row['Sponsor'];

?>
Then presently, I'm using an echo to call a specific field of data from the table:

Quote:
<?php echo $name; ?>
__________________
Extreme Link List - v1.0
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-18-2022, 12:49 AM   #4
natkejs
Confirmed User
 
Industry Role:
Join Date: Jan 2003
Location: Nomad Land
Posts: 1,629
Quote:
Originally Posted by Publisher Bucks View Post
It gets opened at the top of the page:



Then presently, I'm using an echo to call a specific field of data from the table:
Ok so the sponsor column has already been extracted into $sponsor.
Instead of printing $name lets print $string which we will add strong tags to in case $sponsor is set to "Yes".

PHP Code:
$string = ( $sponsor == 'Yes' ) ? "<strong>$name</strong>" $name;
echo 
$string
You could also use a full if / else statement together with $name only but I think it's less fancy for some reason.
Though if you want to do more logic in case $sponsor is set to Yes than this would be a better way to go.

PHP Code:
if ( $sponsor == 'Yes' ) {
 echo 
"<strong>$name</strong>";
}
else {
 echo 
$name;

__________________
natkejs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
field, screwing, where/what, sponsor, query, sql, quick, statement, question, data, meets, criteria, bold, database, entry



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.