Jump to content

Recommended Posts

I get just 1 value for the select query...

I just want to display the returned value

Where did i go wrong ??

 

<?php

$con = mysql_connect("localhost","root","administrator");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

  mysql_select_db("test", $con);

  $result = mysql_query("SELECT details FROM test where first_name like "%Scooter%"");

  $row = mysql_fetch_row($result);

  echo $row;

  mysql_close($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/74717-solved-where-did-i-go-wrong-new-to-php/
Share on other sites

if you just want everything from the details column with no search creteria just do

 

<?php

$con = mysql_connect("localhost","root","administrator");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

  mysql_select_db("test", $con);

  $result = mysql_query("SELECT details FROM test);

  $row = mysql_fetch_row($result);

  echo $row;

  mysql_close($con);

?>

 

i think that will return everything from the details column. I am not sure as i cant test it as i am at work

adam, that dint work..

 

This one worked

 

<?php

$con = mysql_connect("localhost","root","administrator");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("test", $con);

 

$result = mysql_query("SELECT details FROM test WHERE first_name LIKE '%scooter'");

 

while($row = mysql_fetch_array($result))

  {

 

  echo $row['details'];

 

  }

 

mysql_close($con);

?>

 

 

is there a way to do it without the while loop??

like i said i am new to this. I dont this you can do it without the while loop. This is because the while loop is saying that while there is information in the table to be displayed echo it. All tutorials i have looked at always have the while loop.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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