close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Whats wrong with this statement

Thread began 6/22/2012 11:54 pm by akstudio | Last modified 8/28/2013 6:25 pm by tim299030 | 1967 views | 30 replies |

akstudio

Whats wrong with this statement

<?php
if ($row_DetailRS1['isVideo'] == 1)
{
echo '<div id="video_player"></div>';
}
else
{
echo '<div class="large-img">
<img src="images/portfolio/<?php echo $row_DetailRS1["image-lg"]; ?>" width="936" alt="" />
</div>';
}
?>



The output of <?php echo $row_DetailRS1["image-lg"]; ?> on the page looks like this:

" width="936" alt="" />

I cannot see where the issue is. If I take that EXACT code and place it outside the if statement, it works perfect.

Everything works as intended except that line... ugh.

thanks.

Sign in to reply to this post

CraigRBeta Tester

try putting the "image-lg" in single quotes

Sign in to reply to this post

Ray BorduinWebAssist

You have an echo nested in an echo...

It should be

<?php
if ($row_DetailRS1['isVideo'] == 1)
{
echo '<div id="video_player"></div>';
}
else
{
echo '<div class="large-img">
<img src="images/portfolio/'.$row_DetailRS1["image-lg"].'" width="936" alt="" />
</div>';
}
?>

Sign in to reply to this post

tim299030

I want to do something similar but can't get mine to work. Basically, some of my books have downloadable excerpts and some do not.

I have created a custom field in the ps4_products database called ProductExcerpt. If the book has an excerpt, then the name of the excerpt is in the ProductExcerpt field. If there is no excerpt for a specific book, there is nothing in that field.

I want to make it so that if there is an excerpt, there will be a link to the the pdf showing "Read excerpt". If there is not an excerpt, I don't want anything to show.



<?php
if ($ProductExcerpt['ProductExcerpt'] = !"")
{
echo '<a href="https://mywebsite.com/excerpts/'.$ProductExcerpt['ProductExcerpt'].'.pdf">Read excerpt</a>';
}
else
{
echo '';
}
?>

It seems simple but I just can't get it to work.

Thanks for any responses.

Sign in to reply to this post

Jason ByrnesWebAssist

what is the recordset name?

when referring to a recordset result, you us:
$row_recordsetName['columnName']

as the reference.

Sign in to reply to this post

tim299030

Ahhh... -- the recordset name is Recordset1 (forgot to name it).

So my statement now looks like this:

<?php
if ($row_Recordset1['ProductExcerpt'] = !"")
{
echo '<a href="https://mywebsite.com/excerpts/'.$row_Recordset1['ProductExcerpt'].'.pdf">Read excerpt</a>';
}
else
{
echo '';
}
?>

So now when I hold my cursor over the link that is showing it gives me:

https://mywebsite.com/excerpts/1.pdf

INSTEAD I WANT IT TO BE

https://mywebsite.com/excerpts/0788026356.pdf


My recordset is:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_PowerStoreConnection, $PowerStoreConnection);
$query_Recordset1 = "SELECT ProductExcerpt FROM ps4_products";
$Recordset1 = mysql_query($query_Recordset1, $PowerStoreConnection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

Thanks for your help.

Sign in to reply to this post

Jason ByrnesWebAssist

that recordset will only return the first record. you will need to add a where clause to return the specific record you want.

Sign in to reply to this post

tim299030

Okay -- hmm..., so I tried this:

SELECT ProductID, ProductExcerpt
FROM ps4_products
WHERE ProductID = %s

and it didn't work.

So how do I point to that specific record?

Sign in to reply to this post

Jason ByrnesWebAssist

you need to insert the produce number

WHERE ProductID = 123

Sign in to reply to this post

tim299030

But how do I do that dynamically? Can I put ['ProductID'] in the sequel statement?

SELECT ProductID, ProductExcerpt
FROM ps4_products
WHERE ProductID = ['ProductID']

Or do I need to create a variable for that? I'm not sure how to create a variable.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...